← d4ea5a7deae6 · d5178d26d905 →

d4f2f542248a

Mark each blank cell that lies on every shortest non-wall path from the red start to the green goal.

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 (record-of p records)
      (find-first (lambda (rec) (same-pos? p (first rec))) records))
    (define (set-record-count p new-count records)
      (map
        (lambda (rec)
          (if (same-pos? p (first rec))
              (list (first rec) (second rec) new-count)
              rec))
        records))
    (define (neighbors p)
      (filter
        (lambda (n)
          (let ((nr (fst n)) (nc (snd n)))
            (and (in-bounds? nr nc h w) (not (= (cell-at g nr nc) 5)))))
        (map (lambda (d) (list (+ (fst p) (fst d)) (+ (snd p) (snd d)))) cardinal-deltas)))
    (define (dist-count start)
      (let loop ((queue (list start)) (records (list (list start 0 1))))
        (if (empty? queue)
            records
            (let* ((cur (first queue))
                   (restq (cdr queue))
                   (cur-rec (record-of cur records))
                   (cur-dist (second cur-rec))
                   (cur-count (third cur-rec)))
              (let update ((ns (neighbors cur)) (q restq) (recs records))
                (if (empty? ns)
                    (loop q recs)
                    (let* ((n (first ns))
                           (nd (+ cur-dist 1))
                           (hit (record-of n recs)))
                      (cond
                        [(not hit)
                         (update (cdr ns) (append q (list n)) (append recs (list (list n nd cur-count))))]
                        [(= (second hit) nd)
                         (update (cdr ns) q (set-record-count n (+ (third hit) cur-count) recs))]
                        [else (update (cdr ns) q recs)]))))))))
    (let* ((start (first (find-color g 2)))
           (goal (first (find-color g 3)))
           (from-start (dist-count start))
           (from-goal (dist-count goal))
           (goal-rec (record-of goal from-start)))
      (if (not goal-rec)
          g
          (let ((D (second goal-rec))
                (total (third goal-rec)))
            (grid-from-fn h w
              (lambda (r c)
                (let* ((v (cell-at g r c))
                       (p (list r c))
                       (rs (record-of p from-start))
                       (rg (record-of p from-goal)))
                  (if (and (= v 0)
                           rs rg (= (+ (second rs) (second rg)) D)
                           (= (* (third rs) (third rg)) total))
                      8
                      v)))))))))

Provenance

Generator
generators/d4f2f542248a/generator.py
Notes and decisions
generators/d4f2f542248a/notes.md
Review label
reviewed_safe
Generator SHA-256
b5d3642b2f9dca75db864045d4b16687c1feeb5c187af307bafedb57a1710793
Rule hash
de5e86ab7e23
Sources
bank:0d41ded5f4cd
Lesson seeds
20261108, 20261109, 20261110, 20261111, 20261112
Reproduce lesson 1
arcpuzzles generate d4f2f542248a --count 1 --seed 20261108 --test 1