← 371eb0221101 · 37348ddf20d0 →
372fcf6aa6ad
A 0-background grid contains 3-5 isolated, distinctly colored objects. For each object, crop to its bounding box and count enclosed 0-regions. Sort objects lexicographically by (hole count, nonzero-cell count, bbox top row, bbox left column), rotate each crop 90 degrees clockwise, then pack the rotated crops left-to-right with one blank column between them and vertical center alignment.
parametric familygallery constructionhole countingrotationsorting
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 (nonzero-cells grid) (filter (lambda (p) (not (= (at grid (first p) (second p)) 0))) (grid-positions grid))) (define (crop-nonzero grid) (let ((cells (nonzero-cells grid))) (if (empty? cells) (list (list 0)) (let* ((bb (bbox-of-cells cells))) (subgrid grid (first bb) (second bb) (third bb) (fourth bb)))))) (define (fifth xs) (list-ref xs 4)) (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 (f14b-hstack-center grids (gap 1)) (if (empty? grids) (list (list)) (let* ((h (apply max (map rows grids))) (w (+ (apply + (map cols grids)) (* gap (- (length grids) 1))))) (let loop ((xs grids) (left 0) (out (empty-grid h w 0))) (if (empty? xs) out (let* ((piece (first xs)) (top (quotient (- h (rows piece)) 2))) (loop (rest xs) (+ left (cols piece) gap) (e8b-paste out piece top left)))))))) (define (f14b-binary-crop grid) (crop-nonzero (grid-from-fn (rows grid) (cols grid) (lambda (r c) (if (= (at grid r c) 0) 0 1))))) (define (f14b-hole-count grid) (let* ((binary (f14b-binary-crop grid)) (regions (find-0-regions binary 0))) (length (filter (lambda (region) (not (any? (lambda (p) (or (= (first p) 0) (= (first p) (- (rows binary) 1)) (= (second p) 0) (= (second p) (- (cols binary) 1)))) region))) regions)))) (define (s17b-object-crop grid obj) (let ((bb (obj-bbox obj))) (subgrid grid (first bb) (second bb) (third bb) (fourth bb)))) (let* ((items (map (lambda (obj) (let* ((crop (s17b-object-crop g obj)) (holes (f14b-hole-count crop)) (bb (obj-bbox obj))) (list holes (obj-size obj) (first bb) (second bb) (rotate-cw crop)))) (objects g 0))) (sorted (sort items (lambda (a b) (e8b-list< (list (first a) (second a) (third a) (fourth a)) (list (first b) (second b) (third b) (fourth b))))))) (f14b-hstack-center (map fifth sorted) 1))))
Provenance
- Generator
- generators/372fcf6aa6ad/generator.py
- Notes and decisions
- generators/372fcf6aa6ad/notes.md
- Review label
- reviewed_safe
- Generator SHA-256
- 47e6163225c8c29a258907ccb74d4f7cd412d587b0d7ac1c2e884207c9c4c143
- Rule hash
- 35efb067e49f
- Sources
- bank:ad4abc25f505
- Lesson seeds
- 20261108, 20261109, 20261110, 20261111, 20261112
- Reproduce lesson 1
arcpuzzles generate 372fcf6aa6ad --count 1 --seed 20261108 --test 1