← df74e338b4f5 · dfa5c1702b4c →

df92ae881dc8

Infer periodic long-run spacing, then extend full columns or choose the maximal nested-L completion; fill non-path cells gray.

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!
 ;; Concentric L-brackets of one color continue outward forever: detect
 ;; the ring PERIOD (spacing of long-run rows/cols), then either
 ;; replicate any full columns every period toward the open side, or
 ;; grow the longest horizontal run as ever-larger nested Ls in
 ;; whichever diagonal direction covers the most cells. Painted cells
 ;; keep the color; everything else turns gray(5).
 (lambda (g)
   (let ((unused 0))
     (define fg (find-first (lambda (v) (> v 0)) (grid-colors g -999)))
     (define (has? r c) (= (at g r c) fg))
     (define fg-cells (find-color g fg))
     (define (max-run line-len cell-at)  ;; longest fg run along a line
       (first (for/fold ((state (list 0 0))) ((i (range 0 line-len)))
                (if (cell-at i)
                    (list (max (first state) (+ (second state) 1))
                          (+ (second state) 1))
                    (list (first state) 0)))))
     (define sig-rows
       (filter (lambda (r) (>= (max-run w (lambda (c) (has? r c))) 3))
               (range 0 h)))
     (define sig-cols
       (filter (lambda (c) (>= (max-run h (lambda (r) (has? r c))) 3))
               (range 0 w)))
     (define (valid-diffs xs)  ;; consecutive gaps in 2..4
       (if (or (empty? xs) (empty? (rest xs)))
           (list)
           (let ((d (- (second xs) (first xs))))
             (append (if (and (>= d 2) (<= d 4)) (list d) (list))
                     (valid-diffs (rest xs))))))
     (define period
       (let ((diffs (append (valid-diffs sig-rows) (valid-diffs sig-cols))))
         (if (empty? diffs) 2 (mode-list diffs))))
     (define full-cols
       (filter (lambda (c) (all? (lambda (r) (has? r c)) (range 0 h)))
               (range 0 w)))
     (define (any-in-col? c)
       (and (>= c 0) (< c w) (any? (lambda (r) (has? r c)) (range 0 h))))
     (define (replicate-cols)  ;; full columns march off at the period
       (foldl (lambda (c acc)
                (let ((dir (cond ((and (any-in-col? (- c period))
                                       (< (+ c period) w))
                                  1)
                                 ((and (any-in-col? (+ c period))
                                       (>= (- c period) 0))
                                  -1)
                                 ((< (+ c period) w) 1)
                                 (else -1))))
                  (let loop ((a acc) (cc (+ c (* dir period))))
                    (if (and (>= cc 0) (< cc w))
                        (loop (append (for/list ((r (range 0 h)))
                                        (list r cc))
                                      a)
                              (+ cc (* dir period)))
                        a))))
              fg-cells
              full-cols))
     (define (row-runs r)  ;; maximal fg runs: (r start end len)
       (let loop ((c 0) (runs (list)))
         (cond ((>= c w) runs)
               ((not (has? r c)) (loop (+ c 1) runs))
               (else (let scan ((cc c))
                       (if (and (< (+ cc 1) w) (has? r (+ cc 1)))
                           (scan (+ cc 1))
                           (loop (+ cc 1)
                                 (cons (list r c cc (+ 1 (- cc c)))
                                       runs))))))))
     (define chosen-run  ;; longest run (ties: topmost, leftmost)
       (first (sort-by (filter (lambda (run) (>= (fourth run) 3))
                               (flatmap row-runs (range 0 h)))
                       (lambda (run) (- (+ (* 10000 (fourth run))
                                           (* 100 (first run))
                                           (second run)))))))
     (define (grow-Ls rs cs)  ;; nested Ls stepping (rs,cs) per period
       (let ((r0 (first chosen-run))
             (base (if (= cs 1) (third chosen-run) (second chosen-run))))
         (let loop ((k 1) (acc fg-cells))
           (let ((rr (+ r0 (* rs period k)))
                 (cc (+ base (* cs period k))))
             (cond ((or (< rr 0) (>= rr h)) acc)
                   ((and (>= cc 0) (< cc w))
                    (loop (+ k 1)
                          (append (for/list ((hc (if (= cs 1)
                                                     (range 0 (+ cc 1))
                                                     (range cc w))))
                                    (list rr hc))
                                  (for/list ((vr (if (= rs 1)
                                                     (range 0 (+ rr 1))
                                                     (range rr h))))
                                    (list vr cc))
                                  acc)))
                   (else (loop (+ k 1)
                               (append (for/list ((hc (range 0 w)))
                                         (list rr hc))
                                       acc))))))))
     (define complete-cells
       (if (empty? full-cols)
           (pick-max (for*/list ((rs (list -1 1)) (cs (list -1 1)))
                       (grow-Ls rs cs))
                     (lambda (cells) (length (remove-duplicates cells))))
           (replicate-cols)))
     (cellmap g (r c v)
              (if (member (list r c) complete-cells) fg 5)))))

Provenance

Generator
generators/df92ae881dc8/generator.py
Notes and decisions
generators/df92ae881dc8/notes.md
Review label
reviewed_safe
Generator SHA-256
14f97d8cdbd37f1a9701661349c06a64d59747b633e52c0126c881ae5c357096
Rule hash
0951369de1b8
Sources
augmented, training
Lesson seeds
20261108, 20261109, 20261110, 20261111, 20261112
Reproduce lesson 1
arcpuzzles generate df92ae881dc8 --count 1 --seed 20261108 --test 1