← 492fe98aff2b · 49754d8fa42e →

496bcaf83a46

Count color-8 seeds inside each non-8 rectangular frame, preserve all eligible borders, and fill every frame tied for the maximum count.

countingframe interiorsselection by maximum

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).

Reference rule (Racket)

(rule!
  (let ((dummy 0))
    (define (rect-border? obj)
      (let* ((bb (obj-bbox obj))
             (h (+ (- (third bb) (first bb)) 1))
             (w (+ (- (fourth bb) (second bb)) 1))
             (border-size (- (* h w) (* (max 0 (- h 2)) (max 0 (- w 2))))))
        (and (= (obj-size obj) border-size)
             (all? (lambda (p)
                     (or (= (first p) (first bb)) (= (first p) (third bb))
                         (= (second p) (second bb)) (= (second p) (fourth bb))))
                   (obj-cells obj)))))
    (define rects
      (filter rect-border?
              (apply append
                (map (lambda (color) (objects (keep-only g color) 0))
                     (filter (lambda (color) (not (= color 8))) (grid-colors g 0))))))
    (define scored
      (map (lambda (obj)
             (let* ((bb (obj-bbox obj))
                    (inside (positions-in-rect (+ (first bb) 1) (+ (second bb) 1)
                                               (- (third bb) 1) (- (fourth bb) 1)))
                    (count8 (count-where (lambda (p) (= (at g (first p) (second p)) 8)) inside)))
               (list obj count8)))
           rects))
    (define max-count (apply max (map second scored)))
    (define with-borders
      (for/fold ([out (empty-grid (rows g) (cols g) 0)]) ([item (in-list scored)])
        (paint-cells out (obj-cells (first item)) (obj-color (first item)))))
    (for/fold ([out with-borders]) ([item (in-list scored)])
      (let* ((obj (first item))
             (bb (obj-bbox obj)))
        (if (= (second item) max-count)
            (paint-cells out
                         (positions-in-rect (+ (first bb) 1) (+ (second bb) 1)
                                            (- (third bb) 1) (- (fourth bb) 1))
                         (obj-color obj))
            out)))))

Provenance

Generator
generators/496bcaf83a46/generator.py
Notes and decisions
generators/496bcaf83a46/notes.md
Review label
reviewed_safe
Generator SHA-256
dd1f792dbdc54fbdcba4eaa79d8ec17e98536d9de02a0f40a9aa3a60b25de2ec
Rule hash
703485a20938
Sources
bank:3c7b85b8eeb1
Lesson seeds
20261108, 20261109, 20261110, 20261111, 20261112
Reproduce lesson 1
arcpuzzles generate 496bcaf83a46 --count 1 --seed 20261108 --test 1