← 5430502683a1 · 547c45a21db1 →

54628ce9692d

A modal-background 13x13 grid contains 2..4 separated irregular color-1 pieces. Marker colors that occur exactly twice, on different pieces, form a connected docking tree. For each pair, infer the outward direction of the first marker and place the other marker one cell beyond it. Assemble every piece without overlap and crop to the completed multicolor object. One extra unmatched marker may remain.

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)
         (define bg (mode g -1))
         (define objs
           (sort-by (objects-multicolor g bg)
                    (lambda (obj) (+ (* 1000 (obj-r1 obj)) (obj-c1 obj)))))
         (define comps (map (lambda (i) (list i (nth objs i))) (range 0 (length objs))))
         (define dirs (list (list -1 0) (list 1 0) (list 0 -1) (list 0 1)))
         (define (local-cells obj)
           (map (lambda (p)
                  (list (- (first p) (obj-r1 obj)) (- (second p) (obj-c1 obj))))
                (obj-cells obj)))
         (define (port-dir obj lr lc)
           (let ((cells (local-cells obj))
                 (oh (obj-h obj))
                 (ow (obj-w obj)))
             (let ((best (foldl (lambda (d current)
                                  (let* ((dr (first d))
                                         (dc (second d))
                                         (nr (+ lr dr))
                                         (nc (+ lc dc)))
                                    (if (member (list nr nc) cells)
                                        current
                                        (let ((score (+ (if (member (list (- lr dr)
                                                                          (- lc dc))
                                                                    cells)
                                                            10
                                                            0)
                                                        (if (and (= dr -1) (= lr 0))
                                                            5
                                                            0)
                                                        (if (and
                                                              (= dr 1)
                                                              (= lr (- oh 1)))
                                                            5
                                                            0)
                                                        (if (and (= dc -1) (= lc 0))
                                                            5
                                                            0)
                                                        (if (and
                                                              (= dc 1)
                                                              (= lc (- ow 1)))
                                                            5
                                                            0))))
                                          (if (> score (first current))
                                              (list score dr dc)
                                              current)))))
                                (list -1 0 0)
                                dirs)))
               (list (second best) (third best)))))
         (define markers
           (apply append
                  (map (lambda (comp)
                         (let* ((id (first comp))
                                (obj (second comp))
                                (r0 (obj-r1 obj))
                                (c0 (obj-c1 obj)))
                           (map (lambda (cell)
                                  (let* ((lr (- (first cell) r0))
                                         (lc (- (second cell) c0))
                                         (v (at g (first cell) (second cell)))
                                         (d (port-dir obj lr lc)))
                                    (list v id lr lc (first d) (second d))))
                                (filter (lambda (cell)
                                          (not (= (at g (first cell) (second cell)) 1)))
                                        (obj-cells obj)))))
                       comps)))
         (define edges
           (apply append
                  (map (lambda (color)
                         (let ((ps (filter (lambda (p) (= (first p) color)) markers)))
                           (if (= (length ps) 2)
                               (list (list color (first ps) (second ps)))
                               (list))))
                       (range 1 10))))
         (define (find-place placements id)
           (find-first (lambda (p) (= (first p) id)) placements))
         (define (try-place placements from to)
           (let ((from-place (find-place placements (second from)))
                 (to-place (find-place placements (second to))))
             (if (and from-place (not to-place))
                 (append placements
                         (list (list (second to)
                                     (+ (second from-place)
                                        (third from)
                                        (list-ref from 4)
                                        (- (third to)))
                                     (+ (third from-place)
                                        (fourth from)
                                        (list-ref from 5)
                                        (- (fourth to))))))
                 placements)))
         (define (apply-edge placements edge)
           (let ((a (second edge))
                 (b (third edge)))
             (try-place (try-place placements a b) b a)))
         (define seed-placements
           (if (empty? comps) (list) (list (list (first (first comps)) 0 0))))
         (define placements
           (foldl (lambda (step acc)
                    (foldl (lambda (edge inner) (apply-edge inner edge)) acc edges))
                  seed-placements
                  (range 0 (* 3 (max 1 (length comps))))))
         (define full-placements
           (foldl (lambda (comp acc)
                    (if (find-place acc (first comp))
                        acc
                        (append acc (list (list (first comp) 0 0)))))
                  placements
                  comps))
         (define placed-cells
           (apply append
                  (map (lambda (comp)
                         (let* ((id (first comp))
                                (obj (second comp))
                                (placement (find-place full-placements id))
                                (ro (second placement))
                                (co (third placement))
                                (r0 (obj-r1 obj))
                                (c0 (obj-c1 obj)))
                           (map (lambda (cell)
                                  (list (+ ro (- (first cell) r0))
                                        (+ co (- (second cell) c0))
                                        (at g (first cell) (second cell))))
                                (obj-cells obj))))
                       comps)))
         (define bb
           (bbox-of-cells (map (lambda (p) (list (first p) (second p))) placed-cells)))
         (define r1 (first bb))
         (define c1 (second bb))
         (define r2 (third bb))
         (define c2 (fourth bb))
         (define blank (empty-grid (+ 1 (- r2 r1)) (+ 1 (- c2 c1)) bg))
         (foldl (lambda (p acc)
                  (set-cell acc (- (first p) r1) (- (second p) c1) (third p)))
                blank
                placed-cells)))

Provenance

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