← 7071285d78ce · 70913cf98cee →

7073328cf3f2

On a zero background, red(2) and blue(1) seeds are joined by a gray(5) corridor tree. Gray cells on the red-to-blue shortest path become yellow(4). Off-path corridor regions entering from the red end become red, regions entering from the blue end become blue, and interior off-path regions become yellow.

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!
  ;; Position of the first red(2) cell
  (let* ((red (first (find-color g 2)))
         ;; Position of the first blue(1) cell
         (blue (first (find-color g 1))))
    (define (dist-from start)
      ;; Mutable lookup table for dist
      (define dist (make-hash))
      (define queue (list (cons (first start) (second start))))
      (hash-set! dist (first queue) 0)
      (let bfs ([fuel 0])
        (unless (empty? queue)
          (let ((cur (first queue)))
            (set! queue (rest queue))
            (for ([d (in-list cardinal-deltas)])
              (let ((nr (+ (car cur) (first d)))
                    (nc (+ (cdr cur) (second d))))
                (when (and (in-bounds? nr nc (rows g) (cols g))
                           (not (hash-has-key? dist (cons nr nc)))
                           (member? (at g nr nc) (list 1 2 5)))
                  (hash-set! dist (cons nr nc) (+ (hash-ref dist cur) 1))
                  (set! queue (append queue (list (cons nr nc))))))))
          (bfs (+ fuel 1))))
      dist)
    (define red-dist (dist-from red))
    (define blue-dist (dist-from blue))
    (define path-len (hash-ref red-dist (cons (first blue) (second blue)) 999999))
    (define (path-cell? r c)
      (and (= (at g r c) 5)
           (= (+ (hash-ref red-dist (cons r c) 999999)
                 (hash-ref blue-dist (cons r c) 999999))
              path-len)))
    (define (side-region seed-distance)
      ;; Mutable lookup table for seen
      (define seen (make-hash))
      (define queue (list))
      (define direct-starts (list))
      (define fallback-starts (list))
      (for* ([r (in-range (rows g))] [c (in-range (cols g))])
        (when (and (= (at g r c) 5) (not (path-cell? r c)))
          (define touches-direct #f)
          (define touches-path-end #f)
          (for ([d (in-list cardinal-deltas)])
            (let ((nr (+ r (first d))) (nc (+ c (second d))))
              (when (and (in-bounds? nr nc (rows g) (cols g))
                         (= (hash-ref seed-distance (cons nr nc) 999999) 0))
                (set! touches-direct #t))
              (when (and (in-bounds? nr nc (rows g) (cols g))
                         (path-cell? nr nc)
                         (<= (hash-ref seed-distance (cons nr nc) 999999) 1))
                (set! touches-path-end #t))))
          (when touches-direct
            (set! direct-starts (cons (cons r c) direct-starts)))
          (when touches-path-end
            (set! fallback-starts (cons (cons r c) fallback-starts)))))
      (for ([start (in-list (if (empty? direct-starts) fallback-starts direct-starts))])
        (hash-set! seen start #t)
        (set! queue (append queue (list start))))
      (let bfs ([fuel 0])
        (unless (empty? queue)
          (let ((cur (first queue)))
            (set! queue (rest queue))
            (for ([d (in-list cardinal-deltas)])
              (let ((nr (+ (car cur) (first d)))
                    (nc (+ (cdr cur) (second d))))
                (when (and (in-bounds? nr nc (rows g) (cols g))
                           (= (at g nr nc) 5)
                           (not (path-cell? nr nc))
                           (not (hash-has-key? seen (cons nr nc))))
                  (hash-set! seen (cons nr nc) #t)
                  (set! queue (append queue (list (cons nr nc))))))))
          (bfs (+ fuel 1))))
      seen)
    (define red-side (side-region red-dist))
    (define blue-side (side-region blue-dist))
    (grid-from-fn (rows g) (cols g)
      (lambda (r c)
        (let ((v (at g r c)))
          (if (= v 5)
              (cond [(path-cell? r c) 4]
                    [(hash-has-key? red-side (cons r c)) 2]
                    [(hash-has-key? blue-side (cons r c)) 1]
                    [else 4])
              v))))))

Provenance

Generator
generators/7073328cf3f2/generator.py
Notes and decisions
generators/7073328cf3f2/notes.md
Review label
reviewed_safe
Generator SHA-256
0b3cfe143755cf64b3f9e090eb08e39c7caeb3ec877c6125b541153398261706
Rule hash
1047ef160c66
Sources
custom
Lesson seeds
20261108, 20261109, 20261110, 20261111, 20261112
Reproduce lesson 1
arcpuzzles generate 7073328cf3f2 --count 1 --seed 20261108 --test 1