← 1eff2cf0e8d8 · 1f9fef86a482 →
1f3e27c86f7a
Copy a nested template payload into same-color plain rectangles, using border presence for proportional or edge-aligned mapping; without a template, stretch a symmetric stripe's center run into the rectangle.
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!
;; TEMPLATE objects (bbox holds another color) show how each color's
;; block is decorated. Every PLAIN block copies its color's template
;; interior (largest template per color wins): sides where the template
;; border is missing align to that edge, bordered axes scale
;; proportionally. A plain block whose color has NO template instead
;; takes a symmetric striped row pattern (first=last=its color) with
;; the middle run stretched to the block's width.
(lambda (g)
(let ()
(define objs (objects g 0))
(define (has-inner? o)
(not (all? (lambda (p)
(let ((v (at g (first p) (second p))))
(or (= v 0) (= v (obj-color o)))))
(positions-in-rect (obj-r1 o) (obj-c1 o)
(obj-r2 o) (obj-c2 o)))))
(define plains (filter (lambda (o) (not (has-inner? o))) objs))
(define tmpls ;; one template per color, largest first
(let loop ((rem (sort-by (filter has-inner? objs)
(lambda (o) (- (obj-size o)))))
(seen (list)) (acc (list)))
(cond ((empty? rem) (reverse acc))
((member? (obj-color (first rem)) seen)
(loop (rest rem) seen acc))
(else (loop (rest rem)
(cons (obj-color (first rem)) seen)
(cons (first rem) acc))))))
(define tmpl-colors (map obj-color tmpls))
(define (runs vals) ;; run-length encode: ((value count) ...)
(if (empty? vals)
(list)
(let loop ((rem (rest vals)) (cur (first vals)) (n 1)
(acc (list)))
(cond ((empty? rem) (reverse (cons (list cur n) acc)))
((= (first rem) cur) (loop (rest rem) cur (+ n 1) acc))
(else (loop (rest rem) (first rem) 1
(cons (list cur n) acc)))))))
(define stripes ;; rows: solid nonzero span, symmetric, >=3 odd runs
(filter values
(for/list ((r (range 0 h)))
(let ((cs (filter (lambda (c) (> (at g r c) 0))
(range 0 w))))
(if (empty? cs)
#f
(let ((vals (for/list ((c (range (min-list cs)
(+ (max-list cs) 1))))
(at g r c))))
(if (and (all? (lambda (v) (> v 0)) vals)
(> (length (remove-duplicates vals)) 1)
(= (first vals) (last vals))
(odd? (length (runs vals)))
(>= (length (runs vals)) 3))
vals
#f)))))))
(define (fit-center-run vals target-w)
;; same runs, middle run stretched so the total width = target-w
(let* ((rs (runs vals)) (n (length rs)) (mid (quotient n 2))
(mid-len (- target-w
(for/sum ((i (range 0 n))
#:when (not (= i mid)))
(second (nth rs i))))))
(if (< mid-len 1)
#f
(apply append
(for/list ((i (range 0 n)))
(make-list (if (= i mid) mid-len (second (nth rs i)))
(first (nth rs i))))))))
(define (depth limit full-at?) ;; solid border thickness from an edge
(let loop ((d 0))
(if (and (< d limit) (full-at? d)) (loop (+ d 1)) d)))
(define (dress out tmpl)
(let* ((pc (obj-color tmpl))
(tr1 (obj-r1 tmpl)) (tc1 (obj-c1 tmpl))
(tr2 (obj-r2 tmpl)) (tc2 (obj-c2 tmpl))
(row-full (lambda (r) (all? (lambda (c) (= (at g r c) pc))
(range tc1 (+ tc2 1)))))
(col-full (lambda (c) (all? (lambda (r) (= (at g r c) pc))
(range tr1 (+ tr2 1)))))
(top-b (depth (obj-h tmpl) (lambda (d) (row-full (+ tr1 d)))))
(bot-b (depth (obj-h tmpl) (lambda (d) (row-full (- tr2 d)))))
(left-b (depth (obj-w tmpl) (lambda (d) (col-full (+ tc1 d)))))
(right-b (depth (obj-w tmpl) (lambda (d) (col-full (- tc2 d)))))
(ti-r1 (+ tr1 top-b)) (ti-r2 (- tr2 bot-b))
(ti-c1 (+ tc1 left-b)) (ti-c2 (- tc2 right-b))
(ti-h (+ 1 (- ti-r2 ti-r1))) (ti-w (+ 1 (- ti-c2 ti-c1)))
(scale (lambda (i span-in span-out)
(min (inexact->exact
(round (* (/ (+ 0.0 i)
(+ 0.0 (max 1 span-in)))
span-out)))
span-out))))
(for/fold ((acc out))
((plain (in-list (filter (lambda (p)
(= (obj-color p) pc))
plains))))
(let* ((pi-r1 (+ (obj-r1 plain) top-b))
(pi-r2 (- (obj-r2 plain) bot-b))
(pi-c1 (+ (obj-c1 plain) left-b))
(pi-c2 (- (obj-c2 plain) right-b))
(pi-h (+ 1 (- pi-r2 pi-r1)))
(pi-w (+ 1 (- pi-c2 pi-c1))))
(if (and (> ti-h 0) (> ti-w 0) (> pi-h 0) (> pi-w 0))
(for*/fold ((a acc)) ((r (range pi-r1 (+ pi-r2 1)))
(c (range pi-c1 (+ pi-c2 1))))
(let* ((sr (cond ((zero? bot-b)
(min (+ ti-r1 (- r pi-r1)) ti-r2))
((zero? top-b)
(max ti-r1 (- ti-r2 (- pi-r2 r))))
(else (+ ti-r1 (scale (- r pi-r1)
(- pi-h 1)
(- ti-h 1))))))
(sc (cond ((zero? right-b)
(min (+ ti-c1 (- c pi-c1)) ti-c2))
((zero? left-b)
(max ti-c1 (- ti-c2 (- pi-c2 c))))
(else (+ ti-c1 (scale (- c pi-c1)
(- pi-w 1)
(- ti-w 1))))))
(lc (at g sr sc)))
(if (and (> lc 0) (not (= lc pc)))
(set-cell a r c lc)
a)))
acc)))))
(define (stripe out plain)
(let ((pc (obj-color plain)) (pw (obj-w plain)))
(if (member? pc tmpl-colors)
out
(let ((fitted
(find-first (lambda (x) x)
(map (lambda (vals)
(if (and (= (first vals) pc)
(= (last vals) pc))
(fit-center-run vals pw)
#f))
stripes))))
(if fitted
(for*/fold ((a out))
((r (range (obj-r1 plain)
(+ (obj-r2 plain) 1)))
(i (range 0 pw)))
(set-cell a r (+ (obj-c1 plain) i) (nth fitted i)))
out)))))
(for/fold ((out (for/fold ((o g)) ((t (in-list tmpls))) (dress o t))))
((p (in-list plains)))
(stripe out p)))))Provenance
- Generator
- generators/1f3e27c86f7a/generator.py
- Notes and decisions
- generators/1f3e27c86f7a/notes.md
- Review label
- reviewed_safe
- Generator SHA-256
- fb3423280d6ce185d069b4d947f9181787f290aefe0b4f1b5f2b41f55910a117
- Rule hash
- a3f0a934419a
- Sources
- training
- Lesson seeds
- 20261108
- Reproduce lesson 1
arcpuzzles generate 1f3e27c86f7a --count 1 --seed 20261108 --test 1