← 33275a4aae3e · 337ce626a05f →

334cbd1692c7

Variable-size 0-bg grid (14..30) with: (a) a large RECTANGLE (varied size) in some color (rect_color); (b) one MARKER cell of a different color at the rectangle's center; (c) outside the rectangle: a KEY shape — a marker-colored center cell with 4 ARM segments extending up/down/left/right (each arm is 2 cells of a distinct color: up-color, down-color, left-color, right-color). Rule: detect bg = most common color. Detect rect_color = most common non-bg. Find rectangle objects of that color. Compute marker_color from cells inside the rect that are neither bg nor rect_color (mode). Find OUTSIDE marker cells (same color, not in any rect). The one with most nearby non-bg neighbors = KEY CENTER. Grow the key region from the center via 8-conn non-bg cells outside rects. Then for every marker inside each rectangle, STAMP the key's offsets (relative to key center) at that marker's position, painted in the corresponding key arm colors.

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!
 ;; Rectangles of the second-most-common color hold marker dots. A KEY
 ;; glyph sits outside them (rooted at the densest marker): its cells
 ;; two steps out from the center give the four ARM colors, its whole
 ;; footprint is the STAMP. For every marker inside a rectangle, draw
 ;; the arms out to the rectangle's edges in the arm colors, then stamp
 ;; the key pattern around the marker (clipped to the rectangle's
 ;; bbox). The key itself is erased.
 (lambda (g)
   (let ()
     (define all-colors (grid-colors g -999))
     (define bg (pick-max all-colors (lambda (c) (count-color g c))))
     (define rect-color
       (pick-max (filter (lambda (c) (not (= c bg))) all-colors)
                 (lambda (c) (count-color g c))))
     (define rects
       (filter (lambda (o) (and (= (obj-color o) rect-color)
                                (>= (obj-size o) 10)))
               (objects g bg)))
     (define (inside? r c rect)
       (and (>= r (obj-r1 rect)) (<= r (obj-r2 rect))
            (>= c (obj-c1 rect)) (<= c (obj-c2 rect))))
     (define (inside-any? r c)
       (any? (lambda (rect) (inside? r c rect)) rects))
     (define marker-color
       (mode-list (for*/list ((rect rects)
                              (r (range (obj-r1 rect) (+ (obj-r2 rect) 1)))
                              (c (range (obj-c1 rect) (+ (obj-c2 rect) 1)))
                              #:when (let ((v (at g r c)))
                                       (and (not (= v bg))
                                            (not (= v rect-color)))))
                    (at g r c))))
     (define key-center  ;; the outside marker in the densest 5x5 patch
       (pick-max (filter (lambda (p)
                           (and (= (at g (first p) (second p)) marker-color)
                                (not (inside-any? (first p) (second p)))))
                         (grid-positions g))
                 (lambda (p)
                   (for*/sum ((r (range (max 0 (- (first p) 2))
                                        (min h (+ (first p) 3))))
                              (c (range (max 0 (- (second p) 2))
                                        (min w (+ (second p) 3)))))
                     (if (= (at g r c) bg) 0 1)))))
     (define key-cells
       (connected-region g (first key-center) (second key-center)
                         (lambda (r c v) (and (not (= v bg))
                                              (not (inside-any? r c))))
                         8))
     (define offsets  ;; key footprint relative to its center, with colors
       (map (lambda (p) (list (- (first p) (first key-center))
                              (- (second p) (second key-center))
                              (at g (first p) (second p))))
            key-cells))
     (define (offset-color dr dc)
       (let ((hit (find-first (lambda (e) (and (= (first e) dr)
                                               (= (second e) dc)))
                              offsets)))
         (and hit (third hit))))
     (define arm-dirs  ;; (dr dc color) for each arm the key defines
       (filter third
               (list (list -1 0 (offset-color -2 0))
                     (list 1 0 (offset-color 2 0))
                     (list 0 -1 (offset-color 0 -2))
                     (list 0 1 (offset-color 0 2)))))
     (define (paint-arm out rect mr mc dir)
       (let ((dr (first dir)) (dc (second dir)) (color (third dir)))
         (cond ((= dr -1)
                (for/fold ((acc out)) ((r (range (obj-r1 rect) mr)))
                  (set-cell acc r mc color)))
               ((= dr 1)
                (for/fold ((acc out)) ((r (range (+ mr 1)
                                                 (+ (obj-r2 rect) 1))))
                  (set-cell acc r mc color)))
               ((= dc -1)
                (for/fold ((acc out)) ((c (range (obj-c1 rect) mc)))
                  (set-cell acc mr c color)))
               (else
                (for/fold ((acc out)) ((c (range (+ mc 1)
                                                 (+ (obj-c2 rect) 1))))
                  (set-cell acc mr c color))))))
     (define (paint-stamp out rect mr mc)
       (for/fold ((acc out)) ((e offsets))
         (let ((rr (+ mr (first e))) (cc (+ mc (second e))))
           (if (inside? rr cc rect)
               (set-cell acc rr cc (third e))
               acc))))
     (for/fold ((out (erase-cells g key-cells bg))) ((rect rects))
       (for/fold ((acc out))
                 ((m (for*/list ((r (range (obj-r1 rect)
                                           (+ (obj-r2 rect) 1)))
                                 (c (range (obj-c1 rect)
                                           (+ (obj-c2 rect) 1)))
                                 #:when (= (at g r c) marker-color))
                       (list r c))))
         (paint-stamp (for/fold ((a acc)) ((dir arm-dirs))
                        (paint-arm a rect (first m) (second m) dir))
                      rect (first m) (second m)))))))

Provenance

Generator
generators/334cbd1692c7/generator.py
Notes and decisions
generators/334cbd1692c7/notes.md
Review label
reviewed_safe
Generator SHA-256
98ed582f4dd2b201907b4aca0396fb47b700389b53e6c575eb5eb9af666e01a5
Rule hash
695c07388555
Sources
training
Lesson seeds
20261108, 20261109, 20261110, 20261111, 20261112
Reproduce lesson 1
arcpuzzles generate 334cbd1692c7 --count 1 --seed 20261108 --test 1