← ca81880afbf3 · cad61106e2b9 →

ca86ad084977

On a zero-background grid with gray(5) wall objects and one checkpoint each of colors 2,3,4,7, find shortest 4-neighbor paths 2->3, 3->4, and 4->7 through non-wall cells. Resolve equal paths in up/down/left/right BFS order, then paint every interior route cell cyan(8), even when that cell was another checkpoint.

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!
  (let ((dummy 0))
    (define (same-pos? a b)
      (and (= (fst a) (fst b)) (= (snd a) (snd b))))
    (define (pos-in? p lst)
      (any? (lambda (q) (same-pos? p q)) lst))
    (define (parent-of p parents)
      (let ((hit (find-first (lambda (entry) (same-pos? p (first entry))) parents)))
        (if hit (second hit) #f)))
    (define (reconstruct goal parents)
      (let loop ((cur goal) (acc (list)))
        (let ((prev (parent-of cur parents)))
          (if prev
              (loop prev (cons cur acc))
              (cons cur acc)))))
    (define (shortest-path start goal)
      (let loop ((visited (list))
                 (queue (list start))
                 (parents (list (list start #f))))
        (if (empty? queue)
            (list)
            (let ((cur (first queue))
                  (restq (cdr queue)))
              (cond
                [(pos-in? cur visited) (loop visited restq parents)]
                [(same-pos? cur goal) (reconstruct goal parents)]
                [else
                 (let* ((new-visited (cons cur visited))
                        (r (fst cur))
                        (c (snd cur))
                        (neighbors
                          (filter
                            (lambda (n)
                              (let ((nr (fst n)) (nc (snd n)))
                                (and (in-bounds? nr nc h w)
                                     (not (= (cell-at g nr nc) 5))
                                     (not (pos-in? n new-visited))
                                     (not (pos-in? n restq)))))
                            (map
                              (lambda (d) (list (+ r (fst d)) (+ c (snd d))))
                              cardinal-deltas))))
                   (loop new-visited
                         (append restq neighbors)
                         (append parents (map (lambda (n) (list n cur)) neighbors))))])))))
    (define (interior path start goal)
      (filter
        (lambda (p) (not (or (same-pos? p start) (same-pos? p goal))))
        path))
    (let* ((p2 (first (find-color g 2)))
           (p3 (first (find-color g 3)))
           (p4 (first (find-color g 4)))
           (p7 (first (find-color g 7)))
           (segments (list (list p2 p3) (list p3 p4) (list p4 p7)))
           (path-cells
             (flatmap
               (lambda (seg)
                 (let* ((start (first seg))
                        (goal (second seg))
                        (path (shortest-path start goal)))
                   (if (empty? path) (list) (interior path start goal))))
               segments)))
      (paint-cells g path-cells 8))))

Provenance

Generator
generators/ca86ad084977/generator.py
Notes and decisions
generators/ca86ad084977/notes.md
Review label
reviewed_safe
Generator SHA-256
54f8993e6eb120488c5ef8aa151e685cef37e08a7455d48015948281cf7f7d16
Rule hash
1c1d9560813f
Sources
bank:e2825ca16ace
Lesson seeds
20261108, 20261109, 20261110, 20261111, 20261112
Reproduce lesson 1
arcpuzzles generate ca86ad084977 --count 1 --seed 20261108 --test 1