← public_eval_a395ee82 · public_eval_a6f40cea →

public_eval_a47bf94d

Trace crossed and occluded wires; complete source diamonds and destination X symbols.

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!
 ;; Cyan wires connect source and destination terminals. Gray crossings preserve
 ;; heading; maroon rectangles hide straight sections or an unambiguous elbow.
 ;; Follow each wire; infer its color/direction from a square, diamond or X,
 ;; then complete a diamond source and an X destination. Background and wires
 ;; remain unchanged. No example grids, coordinates or answers are embedded.
 (lambda (g)
  (let ()
   (define dirs '((-1 0) (0 -1) (0 1) (1 0)))
   (define (plus p d) (list (+ (first p) (first d)) (+ (second p) (second d))))
   (define (minus p q) (list (- (first p) (first q)) (- (second p) (second q))))
   (define (inside p) (and (<= 0 (first p)) (< (first p) (rows g))
                           (<= 0 (second p)) (< (second p) (cols g))))
   (define (val p) (if (inside p) (at g (first p) (second p)) 0))
   (define (wire p) (member (val p) '(5 8 9)))
   (define (neighbors p) (filter wire (map (lambda (d) (plus p d)) dirs)))
   (define ends (for*/list ((r (range (rows g))) (c (range (cols g)))
                  #:when (and (member (at g r c) '(5 8))
                              (= (length (neighbors (list r c))) 1))) (list r c)))
   (define (before p q) (or (< (first p) (first q))
                           (and (= (first p) (first q)) (< (second p) (second q)))))
   (define blocks (map obj-cells (filter (lambda (o) (= (obj-color o) 9)) (objects g 0))))
   (define (segment a b)
    (define dr (cond ((> (first b) (first a)) 1) ((< (first b) (first a)) -1) (else 0)))
    (define dc (cond ((> (second b) (second a)) 1) ((< (second b) (second a)) -1) (else 0)))
    (for/list ((k (range 1 (+ 1 (abs (- (first b) (first a))) (abs (- (second b) (second a)))))))
     (list (+ (first a) (* k dr)) (+ (second a) (* k dc)))))
   (define (trace start)
    (let loop ((p start) (d (minus (first (neighbors start)) start))
               (path (list start)) (fuel (* 2 (rows g) (cols g))))
     (define forward (plus p d))
     (define choices (filter (lambda (q) (or (= (length path) 1)
                                               (not (equal? q (second path))))) (neighbors p)))
     (cond ((= fuel 0) (reverse path))
           ((= (val forward) 9)
            (define exit (let ray ((q forward)) (if (= (val q) 9) (ray (plus q d)) q)))
            (if (member (val exit) '(5 8))
                (loop exit d (append (reverse (segment p exit)) path) (- fuel 1))
                (let ()
                 (define block (find-first (lambda (cells) (member forward cells)) blocks))
                 (define ports
                  (for*/list ((cell block) (outdir dirs)
                   #:when (and (not (equal? (plus cell outdir) p))
                               (member (val (plus cell outdir)) '(5 8))
                               (not (member (val (plus (plus cell outdir) outdir)) '(0 9)))))
                   (list (plus cell outdir) outdir)))
                 (if (= (length ports) 1)
                  (let* ((end (first (first ports))) (outdir (second (first ports)))
                         (corner (if (= (first d) 0) (list (first p) (second end))
                                                    (list (first end) (second p)))))
                   (loop end outdir (append (reverse (append (segment p corner) (segment corner end))) path) (- fuel 1)))
                  (reverse path)))))
           ((wire forward) (loop forward d (cons forward path) (- fuel 1)))
           ((= (length choices) 1)
            (loop (first choices) (minus (first choices) p) (cons (first choices) path) (- fuel 1)))
           (else (reverse path)))))
   (define (marker p)
    (define near (first (neighbors p)))
    (define center (list (- (* 3 (first p)) (* 2 (first near)))
                         (- (* 3 (second p)) (* 2 (second near)))))
    (define colors (filter (lambda (v) (member v '(1 2 3 4 6 7)))
                    (for*/list ((dr '(-1 0 1)) (dc '(-1 0 1))) (val (plus center (list dr dc))))))
    (define color (if (null? colors) 0 (first colors)))
    (list center color (cond ((= color 0) 'blank) ((= (length colors) 9) 'solid)
                            ((= (val center) color) 'x) (else 'diamond))))
   (define raw (map trace ends))
   (define paths (filter (lambda (p) (and (member (last p) ends)
                                         (before (first p) (last p)))) raw))
   (define recovered
    (filter (lambda (x) (> (fourth x) 0))
     (for/list ((path paths))
      (define a (marker (first path))) (define b (marker (last path)))
      (define a-source (or (member (third a) '(solid diamond)) (equal? (third b) 'x)))
      (list path (if a-source (first a) (first b))
                 (if a-source (first b) (first a))
                 (if (> (second a) 0) (second a) (second b))))))
   (define finish 'paired)
   (define (score item) (- (length (first item)) 1))
   (define chosen (if (null? recovered) #f
                      (for/fold ((best (first recovered))) ((item (rest recovered)))
                       (if (> (score item) (score best)) item best))))
   (define (paint out center color kind)
    (for*/fold ((acc out)) ((dr '(-1 0 1)) (dc '(-1 0 1)))
     (define p (plus center (list dr dc)))
     (define active (if (equal? kind 'diamond) (= (+ (abs dr) (abs dc)) 1) (= (abs dr) (abs dc))))
     (if (inside p) (set-cell acc (first p) (second p) (if active color 0)) acc)))
   (for/fold ((out g)) ((item recovered))
    (paint (paint out (second item) (fourth item) 'diamond) (third item)
     (if (and (equal? finish 'longest_sink_orange) (equal? item chosen)) 7 (fourth item)) 'x)))))

Provenance

Generator
generators/public_eval_a47bf94d/generator.py
Notes and decisions
generators/public_eval_a47bf94d/notes.md
Review label
reviewed_safe
Generator SHA-256
267db29c88a08b274c25179dca36614769d544aa008aea8c1fcf7291817bd497
Rule hash
f8ee45355d3b
Sources
evaluation, public_eval:a47bf94d
Lesson seeds
20261108, 20261109, 20261110, 20261111, 20261112
Reproduce lesson 1
arcpuzzles generate public_eval_a47bf94d --count 1 --seed 20261108 --test 1