← fa55db418c9d · fad48869c581 →

fa5bb24054bc

A 0-background grid contains 2..6 connected monochrome panels separated by one or two blank columns. For each panel compute (area, enclosed 4-connected holes). Output the N×N relation matrix: 5 on the diagonal, 6 for equal area and holes, 2 for equal area only, 3 for equal holes only, and 0 otherwise. A four-sample cyclic curriculum constructively teaches every relation, including equal-area/different-hole code 2.

panel parsingrelational outputshape statistics

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 (split-blank-cols grid)
      (let loop ([c 0] [panels (list)])
        (cond [(>= c (cols grid)) (reverse panels)]
              [(all? (lambda (r) (= (at grid r c) 0)) (range 0 (rows grid)))
               (loop (+ c 1) panels)]
              [else
               (let scan ([stop c])
                 (if (or (>= stop (cols grid))
                         (all? (lambda (r) (= (at grid r stop) 0)) (range 0 (rows grid))))
                     (loop (+ stop 1)
                           (cons (subgrid grid 0 c (- (rows grid) 1) (- stop 1)) panels))
                     (scan (+ stop 1))))])))
    (define (shape-area grid)
      (count-where (lambda (cell) (not (= (third cell) 0))) (grid-cells grid)))
    (define (hole-count grid)
      (let* ((occ (map (lambda (p) (list (+ (first p) 1) (+ (second p) 1)))
                       (filter-cells grid (lambda (r c v) (not (= v 0))))))
             (h (+ (rows grid) 2))
             (w (+ (cols grid) 2)))
        (define (free? r c) (not (member? (list r c) occ)))
        (let loop ([remaining (filter (lambda (p) (free? (first p) (second p)))
                                      (positions-in-rect 0 0 (- h 1) (- w 1)))]
                   [holes 0])
          (if (empty? remaining)
              holes
              (let* ((p (first remaining))
                     (region (connected-region (empty-grid h w 0) (first p) (second p)
                               (lambda (r c v) (free? r c)) 4))
                     (touches-edge? (any? (lambda (q)
                                            (or (= (first q) 0) (= (second q) 0)
                                                (= (first q) (- h 1)) (= (second q) (- w 1))))
                                          region)))
                (loop (filter (lambda (q) (not (member? q region))) remaining)
                      (if touches-edge? holes (+ holes 1))))))))
    (define (relation ai hi aj hj same-flag)
      (cond [(= same-flag 1) 5]
            [(and (= ai aj) (= hi hj)) 6]
            [(= ai aj) 2]
            [(= hi hj) 3]
            [else 0]))
    (let* ((panels (map crop-to-content (split-blank-cols g)))
           (infos (map (lambda (p) (list (shape-area p) (hole-count p))) panels))
           (n (length infos)))
      (grid-from-fn n n
        (lambda (r c)
          (let ((a (nth infos r)) (b (nth infos c)))
            (relation (first a) (second a) (first b) (second b) (if (= r c) 1 0))))))))

Provenance

Generator
generators/fa5bb24054bc/generator.py
Notes and decisions
generators/fa5bb24054bc/notes.md
Review label
reviewed_safe
Generator SHA-256
d659db585ae666b9c525b250c09f624da3070624bf9b9c54872e0af366cfbfe3
Rule hash
b6e6c6e2c73c
Sources
bank:63dac95f0c67
Lesson seeds
20261108, 20261109, 20261110, 20261111, 20261112
Reproduce lesson 1
arcpuzzles generate fa5bb24054bc --count 1 --seed 20261108 --test 1