← f8b9516df05e · f9099d7c7e31 →

f8d1d470d522

Construct a branching color-8 route network between two color-9 markers. Color-7 obstacles disable adjacent 8 cells and thereby alter the route. The selected route is shortest first and fewest-turns second; lessons cover both a unique shortest route and an equal-length tie with one uniquely straightest route.

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)))
           (begin
             (define marks (find-color g 9))
             (if (< (length marks) 2)
                 g
                 (let* ((start (fst marks))
                        (goal (snd marks))
                        (dirs (list (list 0 1) (list 1 0) (list 0 -1) (list -1 0)))
                        (best-path #f)
                        (best-len 999)
                        (best-turns 999))
                   (define (adjacent-7? r c)
                     (for/or ((d dirs))
                             (let ((nr (+ r (fst d)))
                                   (nc (+ c (snd d))))
                               (and (in-bounds? nr nc h w) (= (at g nr nc) 7)))))
                   (define (allowed? r c)
                     (let ((v (at g r c)))
                       (and (or (= v 8) (= v 9)) (or (= v 9) (not (adjacent-7? r c))))))
                   (define (better? len turns)
                     (or (< len best-len) (and (= len best-len) (< turns best-turns))))
                   (define (dfs cur path prev-dir turns)
                     (let ((len (length path)))
                       (when
                         (and
                           (<= len best-len)
                           (or (< len best-len) (< turns best-turns)))
                         (if (equal? cur goal)
                             (when
                               (better? len turns)
                               (set! best-len len)
                               (set! best-turns turns)
                               (set! best-path path))
                             (for-each (lambda (d)
                                         (let* ((nr (+ (fst cur) (fst d)))
                                                (nc (+ (snd cur) (snd d)))
                                                (np (list nr nc)))
                                           (when
                                             (and
                                               (in-bounds? nr nc h w)
                                               (allowed? nr nc)
                                               (not (member np path)))
                                             (dfs np
                                                  (append path (list np))
                                                  d
                                                  (if (or
                                                        (not prev-dir)
                                                        (equal? prev-dir d))
                                                      turns
                                                      (+ turns 1))))))
                                       dirs)))))
                   (dfs start (list start) #f 0)
                   (if best-path (paint-cells g best-path 9) g)))))))

Provenance

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