← public_eval_e376de54 · public_eval_e87109e9 →

public_eval_e8686506

Retain the dense scaffold and translate external pieces to tile its rectangle exactly.

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!
 ;; Assemble the scattered pieces by translation, never rotation. The modal
 ;; background is excluded. Foreground area determines rectangle area; retain
 ;; the most densely occupied candidate rectangle (unique in the grammar).
 ;; Solve the remaining cavities with external same-color 8-components.
 (lambda (g)
  (let ()
   (define selection 0)
   (define bg (pick-max (grid-colors g) (lambda (v) (count-color g v))))
   (define fg (filter (lambda (p) (not (= (at g (first p) (second p)) bg))) (grid-positions g)))
   (define n (length fg))
   (define candidates
    (for*/list ((hh (range 1 (+ h 1))) #:when (= (modulo n hh) 0)
                (ww (list (/ n hh))) #:when (and (> ww 0) (<= ww w))
                (rr (range 0 (+ 1 (- h hh)))) (cc (range 0 (+ 1 (- w ww)))))
     (list (count-if (lambda (p) (and (<= rr (first p)) (< (first p) (+ rr hh))
                                     (<= cc (second p)) (< (second p) (+ cc ww)))) fg)
           rr cc hh ww)))
   (define b (pick-max candidates first))
   (define r0 (second b))
   (define c0 (third b))
   (define hh (fourth b))
   (define ww (fifth b))
   (define scaffold (subgrid g r0 c0 (+ r0 hh -1) (+ c0 ww -1)))
   (define outside (build-grid h w (r c)
     (if (and (<= r0 r) (< r (+ r0 hh)) (<= c0 c) (< c (+ c0 ww))) bg (at g r c))))
   (define originals (objects-8 outside bg))
   (define ordered (sort originals (lambda (a b) (> (obj-size a) (obj-size b)))))
   (define (fit remaining board)
    (if (null? remaining)
        (if (= (count-color board bg) 0) '() #f)
        (let* ((p (first remaining)) (shape (normalize-cells (obj-cells p))))
         (for*/or ((rr (range 0 (+ 1 (- hh (obj-h p)))))
                   (cc (range 0 (+ 1 (- ww (obj-w p))))))
          (let ((cells (map (lambda (q) (list (+ rr (first q)) (+ cc (second q)))) shape)))
           (and (andmap (lambda (q) (= (at board (first q) (second q)) bg)) cells)
                (let ((tail (fit (rest remaining) (recolor-cells board cells (obj-color p)))))
                 (and tail (cons (list (index-of originals p) (obj-color p) cells) tail)))))))))
   (define placements (sort (or (fit ordered scaffold) '()) (lambda (a b) (< (first a) (first b)))))
   (define holes (find-color scaffold bg))
   (define chosen
    (cond ((null? placements) '())
          ((= selection 0) placements)
          ((= selection 1) (filter (lambda (p) (member (first holes) (third p))) placements))
          ((= selection 2) (list (first placements)))
          ((= selection 3) (list (pick-max placements (lambda (p) (length (third p))))))
          ((= selection 4) (list (pick-min placements (lambda (p) (length (third p))))))
          ((= selection 5) (filter (lambda (p) (member (last holes) (third p))) placements))
          ((= selection 6) (list (pick-min placements second)))
          ((= selection 7) (list (pick-max placements second)))
          (else '())))
   (if (= selection 9)
       (let* ((colors (remove-duplicates (map (lambda (p) (at scaffold (first p) (second p)))
                                   (filter (lambda (p) (not (= (at scaffold (first p) (second p)) bg)))
                                           (grid-positions scaffold)))))
              (color (pick-max colors (lambda (v) (count-color scaffold v)))))
        (recolor-cells scaffold holes color))
       (for/fold ((out scaffold)) ((p chosen)) (recolor-cells out (third p) (second p)))))))

Provenance

Generator
generators/public_eval_e8686506/generator.py
Notes and decisions
generators/public_eval_e8686506/notes.md
Review label
reviewed_safe
Generator SHA-256
b32a187f463886e4c7b93f9ada29343cc4cd3b06ccc3f3ed2a28382e0f33a730
Rule hash
aa43a23dfbe0
Sources
evaluation, public_eval:e8686506
Lesson seeds
20261108, 20261109, 20261110, 20261111, 20261112
Reproduce lesson 1
arcpuzzles generate public_eval_e8686506 --count 1 --seed 20261108 --test 1