← 5782a1f38509 · 57bafcdde8c3 →
579f1e2dcb4a
Find nonzero 4-connected components, crop them, order by original left edge then top row, and pack the crops left-to-right with one zero column.
parametric familycomponent extractionordering by positionsize-changing packing
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! (let ((dummy 0)) (define dirs4 (list (list -1 0) (list 1 0) (list 0 -1) (list 0 1))) (define (e8b-list< a b) (cond ((empty? a) #f) ((< (first a) (first b)) #t) ((> (first a) (first b)) #f) (else (e8b-list< (rest a) (rest b))))) (define (e8b-paste grid pat top left) (for*/fold ((out grid)) ((r (in-range (rows pat))) (c (in-range (cols pat)))) (let ((v (at pat r c)) (rr (+ top r)) (cc (+ left c))) (if (and (not (= v 0)) (in-bounds? rr cc (rows out) (cols out))) (set-cell out rr cc v) out)))) (define (e5b-nz-components grid) (let loop-pos ((positions (grid-positions grid)) (seen (list)) (acc (list))) (cond ((empty? positions) (reverse acc)) ((or (member? (first positions) seen) (= (at grid (first (first positions)) (second (first positions))) 0)) (loop-pos (rest positions) seen acc)) (else (let bfs ((queue (list (first positions))) (seen2 (cons (first positions) seen)) (cells (list))) (if (empty? queue) (loop-pos (rest positions) seen2 (cons (reverse cells) acc)) (let* ((cur (first queue)) (nbrs (filter (lambda (p) (and (in-bounds? (first p) (second p) (rows grid) (cols grid)) (not (member? p seen2)) (not (= (at grid (first p) (second p)) 0)))) (map (lambda (d) (list (+ (first cur) (first d)) (+ (second cur) (second d)))) dirs4)))) (bfs (append (rest queue) nbrs) (append seen2 nbrs) (cons cur cells))))))))) (define (e5b-crop-cells grid cells) (let ((bb (bbox-of-cells cells))) (subgrid grid (first bb) (second bb) (third bb) (fourth bb)))) (define (e5b-pack-h-top grids) (if (empty? grids) (list (list 0)) (let* ((h (apply max (map rows grids))) (w (+ (apply + (map cols grids)) (- (length grids) 1)))) (let loop ((xs grids) (left 0) (out (empty-grid h w 0))) (if (empty? xs) out (let ((p (first xs))) (loop (rest xs) (+ left (cols p) 1) (e8b-paste out p 0 left)))))))) (let* ((comps (sort (e5b-nz-components g) (lambda (a b) (let ((ba (bbox-of-cells a)) (bb (bbox-of-cells b))) (e8b-list< (list (second ba) (first ba)) (list (second bb) (first bb))))))) (crops (map (lambda (cells) (e5b-crop-cells g cells)) comps))) (e5b-pack-h-top crops))))
Provenance
- Generator
- generators/579f1e2dcb4a/generator.py
- Notes and decisions
- generators/579f1e2dcb4a/notes.md
- Review label
- reviewed_safe
- Generator SHA-256
- 3a85cb419ae1fcb64d626cf6961405cbaf432ed757e67e2bdea3e373fe3b17bb
- Rule hash
- 29c3632de610
- Sources
- bank:61554c4a7bfb
- Lesson seeds
- 20261108, 20261109, 20261110, 20261111, 20261112
- Reproduce lesson 1
arcpuzzles generate 579f1e2dcb4a --count 1 --seed 20261108 --test 1