← 9b5d72b45563 · 9baf979683ef →

9b6d928388be

Find the three hollow gray frames and read each singleton key above its top midpoint. Match key 1/2/3 to the loose object with 0/1/2 enclosed holes, erase all loose source objects, and center each matched crop on the corresponding frame interior without recoloring it.

parametric familyassignmentframestopology

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 ()
    (define (frame? obj)
      (and (= (obj-color obj) 5) (hollow-frame? obj)))
    (define (frame< a b)
      (cell< (list (obj-r1 a) (obj-c1 a))
             (list (obj-r1 b) (obj-c1 b))))
    (define (key-pos frame)
      (list (- (obj-r1 frame) 1)
            (quotient (+ (obj-c1 frame) (obj-c2 frame)) 2)))
    (define (erase-frame+key grid frame)
      (let* ((without-frame (erase-cells grid (obj-cells frame) 0))
             (key (key-pos frame)))
        (if (in-bounds? (first key) (second key) (rows grid) (cols grid))
            (set-cell without-frame (first key) (second key) 0)
            without-frame)))
    (define (floor-half n)
      (if (< n 0)
          (- (quotient (+ (- n) 1) 2))
          (quotient n 2)))
    (define (paste-transparent grid piece top left)
      (for*/fold ((out grid))
                 ((r (in-range (rows piece)))
                  (c (in-range (cols piece))))
        (let ((v (at piece r c)) (rr (+ top r)) (cc (+ left c)))
          (if (and (!= v 0)
                   (in-bounds? rr cc (rows out) (cols out)))
              (set-cell out rr cc v)
              out))))
    (define (center-object grid frame obj source)
      (let* ((piece (crop-object source obj))
             (top (+ (obj-r1 frame) 1
                     (floor-half (- (- (obj-h frame) 2) (rows piece)))))
             (left (+ (obj-c1 frame) 1
                      (floor-half (- (- (obj-w frame) 2) (cols piece))))))
        (paste-transparent grid piece top left)))
    (let* ((frames (sort (filter frame? (objects g 0)) frame<))
           (source (for/fold ((out g)) ((frame (in-list frames)))
                     (erase-frame+key out frame)))
           (loose (objects source 0))
           (base (for/fold ((out (empty-grid (rows g) (cols g) 0)))
                           ((frame (in-list frames)))
                   (paint-cells out (obj-cells frame) 5))))
      (for/fold ((out base)) ((frame (in-list frames)))
        (let* ((key (key-pos frame))
               (value (if (in-bounds? (first key) (second key)
                                      (rows g) (cols g))
                          (at g (first key) (second key))
                          0))
               (candidates
                (filter (lambda (obj)
                          (= (topo-count-holes source obj 0) (- value 1)))
                        loose))
               (chosen (if (empty? candidates)
                           #f
                           (first (sort candidates
                                        (lambda (a b)
                                          (> (obj-size a) (obj-size b)))))))
               (with-key
                (if (in-bounds? (first key) (second key) (rows g) (cols g))
                    (set-cell out (first key) (second key) value)
                    out)))
          (if chosen
              (center-object with-key frame chosen source)
              with-key))))))

Provenance

Generator
generators/9b6d928388be/generator.py
Notes and decisions
generators/9b6d928388be/notes.md
Review label
reviewed_safe
Generator SHA-256
46f7036431769a810efdb8c4813aa93033bc6f3a9aa039a8f92c52020e717fe7
Rule hash
71c56654a6ea
Sources
bank:d994e8798bff
Lesson seeds
20261108, 20261109, 20261110, 20261111, 20261112
Reproduce lesson 1
arcpuzzles generate 9b6d928388be --count 1 --seed 20261108 --test 1