← b71c45e9a3c0 · b765f6c9ebeb →

b7564fb4b95d

Use (0,0) to select the largest same-colored source component and (0,w-1) as a 1/2/3/4 rotation command. Normalize and rotate the source, then center a recolored copy inside every hollow rectangular frame.

parametric familycenteringframe replayobject extractionrotationselector command

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).

Reference rule (Racket)

(rule!
  (let ((dummy 0))
    (define (rect-border? obj)
      (let* ((bb (obj-bbox obj))
             (h (+ (- (third bb) (first bb)) 1))
             (w (+ (- (fourth bb) (second bb)) 1))
             (border-size (- (* h w) (* (max 0 (- h 2)) (max 0 (- w 2))))))
        (and (>= (obj-size obj) 8)
             (= (obj-size obj) border-size)
             (all? (lambda (p)
                     (or (= (first p) (first bb)) (= (first p) (third bb))
                         (= (second p) (second bb)) (= (second p) (fourth bb))))
                   (obj-cells obj)))))
    (define (normalize cells)
      (let ((bb (bbox-of-cells cells)))
        (map (lambda (p) (list (- (first p) (first bb)) (- (second p) (second bb)))) cells)))
    (define (transform cells cmd)
      (let* ((bb (bbox-of-cells cells))
             (h (+ (- (third bb) (first bb)) 1))
             (w (+ (- (fourth bb) (second bb)) 1))
             (raw (map (lambda (p)
                         (let ((r (first p)) (c (second p)))
                           (cond [(= cmd 2) (list c (- h 1 r))]
                                 [(= cmd 3) (list (- h 1 r) (- w 1 c))]
                                 [(= cmd 4) (list (- w 1 c) r)]
                                 [else (list r c)])))
                       cells))
             (rbb (bbox-of-cells raw)))
        (map (lambda (p) (list (- (first p) (first rbb)) (- (second p) (second rbb)))) raw)))
    (define (floor-half x)
      (if (>= x 0) (quotient x 2) (- 0 (quotient (+ (- 0 x) 1) 2))))
    (define (center-stamp out templ frame)
      (let* ((tbb (bbox-of-cells templ))
             (th (+ (- (third tbb) (first tbb)) 1))
             (tw (+ (- (fourth tbb) (second tbb)) 1))
             (ih (- (obj-h frame) 2))
             (iw (- (obj-w frame) 2))
             (sr (+ (obj-r1 frame) 1 (floor-half (- ih th))))
             (sc (+ (obj-c1 frame) 1 (floor-half (- iw tw)))))
        (paint-cells out
                     (map (lambda (p) (list (+ sr (first p)) (+ sc (second p)))) templ)
                     (obj-color frame))))
    (let* ((sel (at g 0 0))
           (cmd (at g 0 (- (cols g) 1)))
           (source (first (sort (filter (lambda (obj) (not (member (list 0 0) (obj-cells obj))))
                                        (objects (keep-only g sel) 0))
                                (lambda (a b) (> (obj-size a) (obj-size b))))))
           (templ (transform (normalize (obj-cells source)) cmd))
           (colors (filter (lambda (color) (and (not (= color sel)) (not (= color cmd)))) (grid-colors g 0)))
           (frames (filter rect-border? (flatmap (lambda (color) (objects (keep-only g color) 0)) colors))))
      (for/fold ([out (empty-grid (rows g) (cols g) 0)]) ([frame (in-list frames)])
        (center-stamp (paint-cells out (obj-cells frame) (obj-color frame)) templ frame)))))

Provenance

Generator
generators/b7564fb4b95d/generator.py
Notes and decisions
generators/b7564fb4b95d/notes.md
Review label
reviewed_safe
Generator SHA-256
e042618b899fa67ad96da1f74a8621e67d18c12d3e3870a829aaed278d3edaa7
Rule hash
dfa4e91b5010
Sources
bank:f3a2e93ae563
Lesson seeds
20261108, 20261109, 20261110, 20261111, 20261112
Reproduce lesson 1
arcpuzzles generate b7564fb4b95d --count 1 --seed 20261108 --test 1