← 419ed66194f2 · 4201f3b3ea1b →

41a5c2fcf25a

A contiguous 2..4-color legend occupies the left of row 0. Rows below contain the same number of separated color-8 components. Rank components by area descending, breaking equal-area ties by top row then left column, and recolor rank i with legend[i]. Scheduled lessons retain examples with equal-area ties and with 8 itself as a legitimate legend color.

parametric familylegend decodingrankingrecoloring

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* ((legend (filter (lambda (v) (not (= v 0))) (first g)))
         (seen (make-hash))
         (comps (list)))
    (for* ([r (in-range 1 (rows g))] [c (in-range (cols g))])
      (unless (or (hash-has-key? seen (cons r c)) (= (at g r c) 0))
        (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))
                             (>= nr 1)
                             (not (= (at g nr nc) 0))
                             (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))))
        (set! comps (cons cells comps))))
    (define sorted-comps
      (sort comps
            (lambda (a b)
              (let ((ba (bbox-of-cells a)) (bb (bbox-of-cells b)))
                (if (= (length a) (length b))
                    (if (= (first ba) (first bb))
                        (< (second ba) (second bb))
                        (< (first ba) (first bb)))
                    (> (length a) (length b)))))))
    (for/fold ([out (grid-from-fn (rows g) (cols g) (lambda (r c) (if (= r 0) (at g r c) 0)))])
              ([cells (in-list sorted-comps)] [idx (in-naturals)])
      (paint-cells out cells (list-ref legend idx)))))

Provenance

Generator
generators/41a5c2fcf25a/generator.py
Notes and decisions
generators/41a5c2fcf25a/notes.md
Review label
reviewed_safe
Generator SHA-256
de46eb17d0f8121e402c86517a6547616cd3f78c198dd3afb839fed6bf7e3c5f
Rule hash
729bc9e3873e
Sources
bank:cc07013acae1
Lesson seeds
20261108, 20261109, 20261110, 20261111, 20261112
Reproduce lesson 1
arcpuzzles generate 41a5c2fcf25a --count 1 --seed 20261108 --test 1