← public_eval_2d0172a1 · public_eval_332f06d7 →

public_eval_31f7f899

Measure vertical bar heights on a common carrier and assign the sorted heights from left to right.

parametric family

Generated by the released generator before publication; every output was computed by its Racket reference rule. White outlines mark the cells the rule changed. Lesson check:

refuted: a demonstration contradicts the rival. survived_all: it fits every demonstration and also gives the intended answer, so it cannot mislead here. ambiguous: it fits every demonstration but answers the query differently. Names are as declared by the generator; a declared shortcut is not guaranteed to fit the original pairs (see the paper’s Limitations).

Original task pairs

From the source task; the reference rule must reproduce them.

Reference rule (Racket)

(rule!
 (let ()
   (define descending #f)
   (define bg (mode g -1))
   (define h (rows g))
   (define w (cols g))
   (define axis-row
     (first
       (filter (lambda (r)
                 (andmap (lambda (c) (not (= (at g r c) bg))) (range w)))
               (range h))))
   (define axis-color (mode (list (list-ref g axis-row)) bg))
   (define (run-end c color)
     (if (and (< c w) (= (at g axis-row c) color))
         (run-end (+ c 1) color)
         c))
   (define (scan c)
     (cond
       ((>= c w) '())
       ((= (at g axis-row c) axis-color) (scan (+ c 1)))
       (else
         (let* ((color (at g axis-row c))
                (end (run-end c color)))
           (cons (list c end color) (scan end))))))
   (define slots (scan 0))
   (define (filled? r slot)
     (andmap (lambda (c) (= (at g r c) (third slot)))
             (range (first slot) (second slot))))
   (define (top-of slot)
     (let loop ((r axis-row))
       (if (and (> r 0) (filled? (- r 1) slot))
           (loop (- r 1))
           r)))
   (define (bottom-of slot)
     (let loop ((r axis-row))
       (if (and (< (+ r 1) h) (filled? (+ r 1) slot))
           (loop (+ r 1))
           r)))
   (define measured
     (map (lambda (slot) (+ 1 (- (bottom-of slot) (top-of slot)))) slots))
   (define assigned (sort measured (if descending > <)))
   (define specs (map list slots assigned))
   (grid-from-fn h w
     (lambda (r c)
       (if (= r axis-row)
           (at g r c)
           (let ((spec (find-first
                         (lambda (x)
                           (and (<= (first (first x)) c)
                                (< c (second (first x)))))
                         specs)))
             (if spec
                 (let* ((slot (first spec))
                        (height (second spec))
                        (top (- axis-row (quotient height 2))))
                   (if (and (<= top r) (< r (+ top height)))
                       (third slot)
                       bg))
                 bg)))))))

Provenance

Generator
generators/public_eval_31f7f899/generator.py
Notes and decisions
generators/public_eval_31f7f899/notes.md
Review label
reviewed_safe
Generator SHA-256
84da8478c9de9ac1f9e0f083e1d560e7dd21f924ced1f7a6a6fd0f456b77d011
Rule hash
66ed1576c8f5
Sources
evaluation, public_eval:31f7f899
Lesson seeds
20261108, 20261109, 20261110, 20261111, 20261112
Reproduce lesson 1
arcpuzzles generate public_eval_31f7f899 --count 1 --seed 20261108 --test 1