← public_eval_62593bfd · public_eval_65b59efc →

public_eval_64efde09

Match rotated/reflected multicolor bars and transfer colored boundary-marker rays to corresponding ports.

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!
 ;; Repeated full multicolor bars are copies under the eight square symmetries.
 ;; An isolated boundary marker looks inward along its boundary normal at the nearest
 ;; bar. Match that bar's colored pattern to every other bar, transport the port
 ;; AND outward normal, and extend a marker-colored ray to the boundary.
 ;; Stop at an original obstacle. Background is modal, smallest color on ties.
 (lambda (g)
  (let ()
   (define limited #f)
   (define colors (grid-colors g))
   (define background
    (for/fold ((best (first colors))) ((color (in-list colors)))
     (if (> (count-color g color) (count-color g best)) color best)))
   (define blobs (objects (cellmap g (r c v) (if (= v background) 0 1)) 0))
   (define bars (filter (lambda (o) (> (obj-size o) 1)) blobs))
   (define seeds (filter (lambda (o) (= (obj-size o) 1)) blobs))
   (define (tile o) (subgrid g (obj-r1 o) (obj-c1 o) (obj-r2 o) (obj-c2 o)))
   (define (turn gg k)
    (cond ((= k 0) gg) ((= k 1) (rotate-cw gg))
          ((= k 2) (rotate-180 gg)) ((= k 3) (rotate-ccw gg))
          ((= k 4) (flip-lr gg)) ((= k 5) (transpose gg))
          ((= k 6) (flip-ud gg)) (else (rotate-180 (transpose gg)))))
   (define (point p k hh ww)
    (let ((r (first p)) (c (second p)))
     (cond ((= k 0) (list r c)) ((= k 1) (list c (- hh 1 r)))
           ((= k 2) (list (- hh 1 r) (- ww 1 c)))
           ((= k 3) (list (- ww 1 c) r))
           ((= k 4) (list r (- ww 1 c))) ((= k 5) (list c r))
           ((= k 6) (list (- hh 1 r) c))
           (else (list (- ww 1 c) (- hh 1 r))))))
   (define (connection s o)
    (let ((r (obj-r1 s)) (c (obj-c1 s))
          (r0 (obj-r1 o)) (c0 (obj-c1 o)) (r1 (obj-r2 o)) (c1 (obj-c2 o)))
     (cond
      ((and (> (obj-h o) (obj-w o)) (<= r0 r r1) (= c 0) (< c c0))
       (list (- c0 c) o (list (- r r0) 0) (list 0 -1)))
      ((and (> (obj-h o) (obj-w o)) (<= r0 r r1) (= c (- w 1)) (> c c1))
       (list (- c c1) o (list (- r r0) (- c1 c0)) (list 0 1)))
      ((and (> (obj-w o) (obj-h o)) (<= c0 c c1) (= r 0) (< r r0))
       (list (- r0 r) o (list 0 (- c c0)) (list -1 0)))
      ((and (> (obj-w o) (obj-h o)) (<= c0 c c1) (= r (- h 1)) (> r r1))
       (list (- r r1) o (list (- r1 r0) (- c c0)) (list 1 0)))
      (else #f))))
   (define (ray out r c dr dc length color)
    (let loop ((rr (+ r dr)) (cc (+ c dc)) (remaining length) (acc out))
     (if (and (> remaining 0) (in-bounds? rr cc h w)
              (or (= (at g rr cc) background) (= (at g rr cc) color)))
         (loop (+ rr dr) (+ cc dc) (- remaining 1) (set-cell acc rr cc color))
         acc)))
   (for/fold ((out g)) ((seed (in-list seeds)))
    (let ((connections (filter (lambda (x) x) (map (lambda (o) (connection seed o)) bars))))
     (if (null? connections) out
      (let* ((source-data (first (sort connections (lambda (a b) (< (first a) (first b))))))
             (distance (first source-data)) (source (second source-data))
             (contact (third source-data)) (normal (fourth source-data))
             (source-tile (tile source)) (hh (obj-h source)) (ww (obj-w source))
             (color (at g (obj-r1 seed) (obj-c1 seed))))
       (for/fold ((acc out)) ((target (in-list bars)))
        (let ((code (for/first ((k (in-range 8)) #:when (equal? (turn source-tile k) (tile target))) k)))
         (if (not code) acc
          (let* ((q (point contact code hh ww))
                 (u (point (list (+ (first contact) (first normal))
                                 (+ (second contact) (second normal))) code hh ww))
                 (dr (- (first u) (first q))) (dc (- (second u) (second q))))
           (ray acc (+ (obj-r1 target) (first q)) (+ (obj-c1 target) (second q))
                dr dc (if limited distance (+ h w)) color))))))))))))

Provenance

Generator
generators/public_eval_64efde09/generator.py
Notes and decisions
generators/public_eval_64efde09/notes.md
Review label
reviewed_safe
Generator SHA-256
455c69b0bcbde3ad54f7e501ebc6571571b1cdcf8c8276be1cbdc9d41bb210cf
Rule hash
c7f8a71fdf3b
Sources
evaluation, public_eval:64efde09
Lesson seeds
20261108, 20261109, 20261110, 20261111, 20261112
Reproduce lesson 1
arcpuzzles generate public_eval_64efde09 --count 1 --seed 20261108 --test 1