← 6ecd6f93877b · 6f6c567e365b →

6ecd8be24495

Gray (5) walls partition a bordered grid into rectangular chambers. Count every nonzero, non-wall seed in each chamber, select the unique chamber with the greatest total seed count, find that chamber's unique majority seed color, and fill only its zero cells with that color.

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!
  (let ((seen (make-hash))
        (best-score #f)
        (best-cells (list))
        (best-color 0))
    (define (score-better? score old)
      (or (not old)
          (> (first score) (first old))
          (and (= (first score) (first old))
               (or (> (second score) (second old))
                   (and (= (second score) (second old))
                        (> (third score) (third old)))))))
    (for* ([r (in-range (rows g))] [c (in-range (cols g))])
      (unless (or (hash-has-key? seen (cons r c)) (= (at g r c) 5))
        (define queue (list (cons r c)))
        (define cells (list))
        (hash-set! seen (first queue) #t)
        (let bfs ([fuel 0])
          (unless (empty? queue)
            (let ((cur (first queue)))
              (set! queue (rest queue))
              (set! cells (cons (list (car cur) (cdr cur)) cells))
              (for ([d (in-list cardinal-deltas)])
                (let ((nr (+ (car cur) (first d))) (nc (+ (cdr cur) (second d))))
                  (when (and (in-bounds? nr nc (rows g) (cols g))
                             (not (= (at g nr nc) 5))
                             (not (hash-has-key? seen (cons nr nc))))
                    (hash-set! seen (cons nr nc) #t)
                    (set! queue (append queue (list (cons nr nc))))))))
            (bfs (+ fuel 1))))
        (let* ((seed-values (filter (lambda (v) (not (= v 0)))
                                    (map (lambda (p) (at g (first p) (second p))) cells))))
          (unless (empty? seed-values)
            (define counts (make-hash))
            (for ([v (in-list seed-values)])
              (hash-update! counts v add1 0))
            (define top-color
              (first (sort (hash-keys counts)
                           (lambda (a b)
                             (if (= (hash-ref counts a) (hash-ref counts b))
                                 (< a b)
                                 (> (hash-ref counts a) (hash-ref counts b)))))))
            (define score (list (length seed-values) (hash-ref counts top-color) (- 0 top-color)))
            (when (score-better? score best-score)
              (set! best-score score)
              (set! best-cells cells)
              (set! best-color top-color))))))
    (for/fold ([out g]) ([p (in-list best-cells)])
      (if (= (at out (first p) (second p)) 0)
          (set-cell out (first p) (second p) best-color)
          out))))

Provenance

Generator
generators/6ecd8be24495/generator.py
Notes and decisions
generators/6ecd8be24495/notes.md
Review label
reviewed_safe
Generator SHA-256
65c5a5b0ccb4e36d21a97ad5e636f46e4ec29d9b2e3347231bae1ff0d8e81b9e
Rule hash
296d35a8cea3
Sources
bank:8edfaf6db623
Lesson seeds
20261108, 20261109, 20261110, 20261111, 20261112
Reproduce lesson 1
arcpuzzles generate 6ecd8be24495 --count 1 --seed 20261108 --test 1