← efdd2b265cc8 · f06d31332595 →

f06819f26831

0-bg grid with 1..3 two-color TEMPLATES (bar3/plus5/diamond5, disjoint color pairs) and isolated single-cell PARTIALS matching template colors. Rule: stamp each template onto each partial of its color.

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! (lambda (g)
         (let* ((h (rows g))
                (w (cols g)))
           (let* ((mcomps (objects-multicolor g 0))
                  (templates (filter (lambda (o)
                                       (let ((colors (remove-duplicates (map (lambda (c)
                                                                               (at g
                                                                                   (first c)
                                                                                   (second c)))
                                                                             (obj-cells o)))))
                                         (>= (length colors) 2)))
                                     mcomps))
                  (tmpl-rels (map (lambda (t)
                                    (let* ((cells (obj-cells t))
                                           (bb (bbox-of-cells cells))
                                           (r1 (first bb))
                                           (c1 (second bb)))
                                      (map (lambda (c)
                                             (list (- (first c) r1)
                                                   (- (second c) c1)
                                                   (at g (first c) (second c))))
                                           cells)))
                                  templates))
                  (tmpl-set (make-hash))
                  (_1 (for ((t templates))
                        (for ((c (obj-cells t)))
                          (hash-set! tmpl-set (list (first c) (second c)) #t))))
                  (partials (reverse (fold-cells g
                                                 (list)
                                                 (lambda (acc r c v)
                                                   (if (and
                                                         (!= v 0)
                                                         (not (hash-has-key? tmpl-set
                                                                             (list r c))))
                                                       (cons (list r c v) acc)
                                                       acc)))))
                  (partial-set (make-hash))
                  (_2 (for ((p partials))
                        (hash-set! partial-set (list (first p) (second p)) (third p))))
                  (candidates (apply append
                                     (map (lambda (p)
                                            (apply append
                                                   (map (lambda (t-rel)
                                                          (map (lambda (tc)
                                                                 (list (- (first p)
                                                                          (first tc))
                                                                       (- (second p)
                                                                          (second tc))
                                                                       t-rel))
                                                               (filter (lambda (tc)
                                                                         (= (third tc)
                                                                            (third p)))
                                                                       t-rel)))
                                                        tmpl-rels)))
                                          partials)))
                  (scored (filter (lambda (x) x)
                                  (map (lambda (cand)
                                         (let* ((off-r (first cand))
                                                (off-c (second cand))
                                                (t-rel (third cand))
                                                (abs-cells (map (lambda (tc)
                                                                  (list (+ (first tc)
                                                                           off-r)
                                                                        (+ (second tc)
                                                                           off-c)
                                                                        (third tc)))
                                                                t-rel))
                                                (valid (let check
                                                            ((cs abs-cells))
                                                            (cond
                                                              ((null? cs) #t)
                                                              (else (let* ((c (car cs))
                                                                           (ar (first c))
                                                                           (ac (second c))
                                                                           (av (third c)))
                                                                      (cond
                                                                        ((not (in-bounds? ar
                                                                                          ac
                                                                                          h
                                                                                          w)) #f)
                                                                        ((hash-has-key? tmpl-set
                                                                                        (list ar
                                                                                              ac)) #f)
                                                                        ((let ((gv (at g
                                                                                       ar
                                                                                       ac)))
                                                                           (or
                                                                             (zero? gv)
                                                                             (= gv av))) (check (cdr cs)))
                                                                        (else #f)))))))
                                                (covered (if valid
                                                             (filter (lambda (ac)
                                                                       (hash-has-key? partial-set
                                                                                      (list (first ac)
                                                                                            (second ac))))
                                                                     abs-cells)
                                                             '
                                                             ())))
                                           (and
                                             (and valid (> (length covered) 0))
                                             (list (length covered) covered abs-cells))))
                                       candidates)))
                  (sorted (sort scored (lambda (a b) (> (first a) (first b)))))
                  (used (make-hash)))
             (for/fold ((out g))
               ((c sorted))
               (let* ((covered (second c))
                      (abs-cells (third c))
                      (overlap (let check
                                    ((cs covered))
                                    (cond
                                      ((null? cs) #f)
                                      ((hash-has-key? used
                                                      (list (first (car cs))
                                                            (second (car cs)))) #t)
                                      (else (check (cdr cs)))))))
                 (cond
                   (overlap out)
                   (else (for ((cov covered))
                           (hash-set! used (list (first cov) (second cov)) #t))
                         (paint-cells out abs-cells)))))))))

Provenance

Generator
generators/f06819f26831/generator.py
Notes and decisions
generators/f06819f26831/notes.md
Review label
reviewed_safe
Generator SHA-256
86875bec92c930ea689dc3b9ff09e889a0507a931433f49719e648e71d49234d
Rule hash
f962984a2a44
Sources
augmented, training
Lesson seeds
20261108, 20261109, 20261110, 20261111, 20261112
Reproduce lesson 1
arcpuzzles generate f06819f26831 --count 1 --seed 20261108 --test 1