← 44e865b6a43e · 457b4958145b →

4512012999bb

Find paired vertical guides, orient a separately bounded crop by side-color score, and insert it between the preserved guide walls.

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! (lambda (g)
         (let* ((h (rows g))
                (w (cols g)))
           (let* ((all-cells (flatmap (lambda (r)
                                        (map (lambda (c) (list r c)) (range 0 w)))
                                      (range 0 h)))
                  (best #f))
             (define (segment? c r0 r1)
               (and
                 (!= (at g r0 c) 0)
                 (= (at g r0 c) (at g r1 c))
                 (all? (lambda (r) (!= (at g r c) 0)) (range r0 (+ r1 1)))))
             (define (guide-cell? p r0 r1 cL cR)
               (and (>= (fst p) r0) (<= (fst p) r1) (or (= (snd p) cL) (= (snd p) cR))))
             (define (pat-cells r0 r1 cL cR)
               (filter (lambda (p)
                         (and
                           (!= (at g (fst p) (snd p)) 0)
                           (not (guide-cell? p r0 r1 cL cR))))
                       all-cells))
             (define (try-pair r0 r1 cL cR)
               (let* ((oh (+ 1 (- r1 r0)))
                      (ow (+ 1 (- cR cL)))
                      (cells (pat-cells r0 r1 cL cR)))
                 (unless
                   (empty? cells)
                   (let* ((pr0 (min-of fst cells))
                          (pr1 (max-of fst cells))
                          (pc0 (min-of snd cells))
                          (pc1 (max-of snd cells)))
                     (when
                       (and
                         (= (+ 1 (- pr1 pr0)) (- oh 2))
                         (= (+ 1 (- pc1 pc0)) (- ow 2)))
                       (set! best (list r0 r1 cL cR pr0 pr1 pc0 pc1)))))))
             (for* ((r0 (range 0 h)) (r1 (range (+ r0 2) h))
                     (cA (range 0 w))
                     (cB (range (+ cA 1) w)))
                   (when
                     (and (not best) (segment? cA r0 r1) (segment? cB r0 r1))
                     (try-pair r0 r1 cA cB)))
             (let* ((r0 (first best))
                    (r1 (second best))
                    (cL (third best))
                    (cR (fourth best))
                    (pr0 (fifth best))
                    (pc0 (seventh best))
                    (pc1 (eighth best))
                    (oh (+ 1 (- r1 r0)))
                    (ow (+ 1 (- cR cL)))
                    (ih (- oh 2))
                    (iw (- ow 2))
                    (left (at g (+ r0 1) cL))
                    (right (at g (+ r0 1) cR))
                    (offsets (flatmap (lambda (dr)
                                        (map (lambda (dc) (list dr dc)) (range 0 iw)))
                                      (range 0 ih))))
               (define (src-val off flip?)
                 (let ((dr (fst off))
                       (dc (snd off)))
                   (at g (+ pr0 dr) (if flip? (- pc1 dc) (+ pc0 dc)))))
               (define (score flip?)
                 (count-if (lambda (off)
                             (let ((dc (snd off))
                                   (v (src-val off flip?)))
                               (or
                                 (and (< dc (quotient iw 2)) (= v left))
                                 (and (>= dc (quotient (+ iw 1) 2)) (= v right)))))
                           offsets))
               (let ((flip? (> (score #t) (score #f))))
                 (build-grid oh
                             ow
                             (r c)
                             (cond
                               ((zero? c) (at g (+ r0 r) cL))
                               ((= c (- ow 1)) (at g (+ r0 r) cR))
                               ((or (zero? r) (= r (- oh 1))) 0)
                               (else (src-val (list (- r 1) (- c 1)) flip?))))))))))

Provenance

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