← public_eval_8b7bacbf · public_eval_8e5c0c38 →

public_eval_8b9c3697

Infer comb middle-tooth lanes, dock nearest compatible red rectangles and blacken their swept trails.

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!
 ;; Each comb has two long guards and a shorter middle tooth. Infer its facing,
 ;; lane width and stopping tip. Among solid red rectangles aligned exactly
 ;; with that lane, select the NEAREST compatible object. Erase other red marks,
 ;; dock the selected rectangle against the middle tooth, and blacken its trail.
 (lambda (g)
   (let ()
     (define bg (mode g -1))
     (define os (objects g bg))
     (define reds (filter (lambda (o) (= (obj-color o) 2)) os))
     (define (dot p d) (+ (* (first p) (first d)) (* (second p) (second d))))
     (define (lo o d) (apply min (map (lambda (p) (dot p d)) (obj-cells o))))
     (define (hi o d) (apply max (map (lambda (p) (dot p d)) (obj-cells o))))
     (define (profile o d)
       (let ()
         (define e (list (- (second d)) (first d)))
         (define t0 (lo o d))
         (define u0 (lo o e))
         (define u1 (hi o e))
         (define heights
           (for/list ((u (range u0 (+ u1 1))))
             (count-if (lambda (p) (= (dot p e) u)) (obj-cells o))))
         (define teeth
           (objects (list (map (lambda (n) (if (> n 1) 1 0)) heights)) 0))
         (if (and (= (apply min heights) 1)
                  (= (length teeth) 3)
                  (for/and ((u (range u0 (+ u1 1))))
                    (for/and ((t (range t0 (+ t0 (list-ref heights (- u u0))))))
                      (member (list (+ (* (first d) t) (* (first e) u))
                                    (+ (* (second d) t) (* (second e) u)))
                              (obj-cells o)))))
             (let ()
               (define a (first teeth))
               (define m (second teeth))
               (define b (third teeth))
               (define ah (list-ref heights (obj-c1 a)))
               (define mh (list-ref heights (obj-c1 m)))
               (define bh (list-ref heights (obj-c1 b)))
               (if (and (= ah bh) (> ah mh) (> mh 1)
                        (for/and ((tooth teeth))
                          (for/and ((c (range (obj-c1 tooth) (+ (obj-c2 tooth) 1))))
                            (= (list-ref heights c) (list-ref heights (obj-c1 tooth))))))
                   (list d e (+ u0 (obj-c1 m)) (+ u0 (obj-c2 m))
                         (+ t0 (- mh 1)) (+ t0 (- ah 1)))
                   #f))
             #f)))
     (define sockets
       (filter (lambda (p) p)
         (for/list ((o os) #:when (not (= (obj-color o) 2)))
           (for/first ((d cardinal-deltas) #:when (profile o d)) (profile o d)))))
     (for/fold ((out (recolor g 2 bg))) ((s sockets))
       (let ()
         (define d (first s))
         (define e (second s))
         (define u0 (third s))
         (define u1 (fourth s))
         (define tip (list-ref s 4))
         (define candidates
           (filter (lambda (o) (and (solid-rect? o) (= (lo o e) u0) (= (hi o e) u1)
                                    (> (lo o d) (list-ref s 4)))) reds))
         (if (null? candidates) out
             (let ()
               (define chosen (pick-min candidates (lambda (o) (lo o d))))
               (define depth (+ 1 (- (hi chosen d) (lo chosen d))))
               (define swept
                 (for*/list ((t (range (+ tip 1) (+ (hi chosen d) 1))) (u (range u0 (+ u1 1))))
                   (list (+ (* (first d) t) (* (first e) u))
                         (+ (* (second d) t) (* (second e) u)))))
               (define dock
                 (for*/list ((t (range (+ tip 1) (+ tip 1 depth))) (u (range u0 (+ u1 1))))
                   (list (+ (* (first d) t) (* (first e) u))
                         (+ (* (second d) t) (* (second e) u)))))
               (recolor-cells (recolor-cells out swept 0) dock 2))))))))

Provenance

Generator
generators/public_eval_8b9c3697/generator.py
Notes and decisions
generators/public_eval_8b9c3697/notes.md
Review label
reviewed_safe
Generator SHA-256
f54105fd7810009c93b497a65ace9b3833ce9c97aa7c35d866132c77e27b3367
Rule hash
3410de671c18
Sources
evaluation, public_eval:8b9c3697
Lesson seeds
20261108, 20261109, 20261110, 20261111, 20261112
Reproduce lesson 1
arcpuzzles generate public_eval_8b9c3697 --count 1 --seed 20261108 --test 1