← public_eval_5545f144 · public_eval_58490d8a →

public_eval_581f7754

No summary in the catalog.

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!
 (lambda (g)
  (let ()
   (define assignment-mode 0) ; 0 = matching marker color, 1 = nearest anchor line
   (define h (rows g))
   (define w (cols g))
   (define bg (mode g -1))
   (define all-objects (objects-multicolor g bg))
   (define (border? p)
    (or (= (first p) 0) (= (second p) 0)
        (= (first p) (- h 1)) (= (second p) (- w 1))))
   (define (anchor-object? o)
    (and (= (obj-size o) 1) (border? (first (obj-cells o)))))
   (define anchor-points
    (sort (map (lambda (o) (first (obj-cells o)))
               (filter anchor-object? all-objects)) cell<))
   (define movable
    (sort (filter (lambda (o) (not (anchor-object? o))) all-objects)
          (lambda (a b)
           (cell< (first (sort (obj-cells a) cell<))
                  (first (sort (obj-cells b) cell<))))))
   (define anchor-colors
    (remove-duplicates
     (map (lambda (p) (at g (first p) (second p))) anchor-points)))
   (define (color-count cells color)
    (length (filter (lambda (p) (= (at g (first p) (second p)) color)) cells)))
   (define (marker-for o)
    (let* ((cells (sort (obj-cells o) cell<))
           (candidates
            (filter (lambda (p) (member? (at g (first p) (second p)) anchor-colors)) cells)))
     (pick-min candidates
      (lambda (p)
       (+ (* 1000 (color-count cells (at g (first p) (second p))))
          (at g (first p) (second p)))))))
   (define (side p)
    (cond ((= (second p) 0) 'left)
          ((= (second p) (- w 1)) 'right)
          ((= (first p) 0) 'top)
          (else 'bottom)))
   (define (line-distance marker anchor)
    (if (member? (side anchor) '(left right))
        (abs (- (first marker) (first anchor)))
        (abs (- (second marker) (second anchor)))))
   (define (anchor-for marker)
    (let* ((mc (at g (first marker) (second marker)))
           (candidates
            (if (= assignment-mode 0)
                (filter (lambda (p) (= (at g (first p) (second p)) mc)) anchor-points)
                anchor-points)))
     (pick-min candidates
      (lambda (p)
       (if (= assignment-mode 0)
           (pos-manhattan marker p)
           (line-distance marker p))))))
   (define (centered-full-three? o marker)
    (let* ((cells (obj-cells o)) (box (obj-bbox o)))
     (and (= (obj-size o) 9)
          (= (- (third box) (first box)) 2)
          (= (- (fourth box) (second box)) 2)
          (= (first marker) (+ (first box) 1))
          (= (second marker) (+ (second box) 1)))))
   (define records
    (map
     (lambda (o)
      (let* ((marker (marker-for o))
             (anchor (anchor-for marker))
             (s (side anchor))
             (dr (if (member? s '(left right)) (- (first anchor) (first marker)) 0))
             (dc (if (member? s '(top bottom)) (- (second anchor) (second marker)) 0))
             (special (centered-full-three? o marker))
             (ndr (+ dr (if (and special (eq? s 'top)) -1
                           (if (and special (eq? s 'bottom)) 1 0))))
             (ndc (+ dc (if (and special (eq? s 'left)) -1
                           (if (and special (eq? s 'right)) 1 0)))))
       (list o ndr ndc)))
     movable))
   (define cleared
    (for*/fold ((out g)) ((o movable) (p (obj-cells o)))
     (set-cell out (first p) (second p) bg)))
   (for*/fold ((out cleared)) ((record records)
                               (p (sort (obj-cells (first record)) cell<)))
    (let ((nr (+ (first p) (second record)))
          (nc (+ (second p) (third record))))
     (if (in-bounds? nr nc h w)
         (set-cell out nr nc (at g (first p) (second p))) out))))))

Provenance

Generator
generators/public_eval_581f7754/generator.py
Notes and decisions
generators/public_eval_581f7754/notes.md
Review label
reviewed_safe
Generator SHA-256
87e6f138d9a780652307b189b6e6bc573d40093cb0955b4d244583006739a7ca
Rule hash
6b32e60e5935
Sources
evaluation, public_eval:581f7754
Lesson seeds
20261108, 20261109, 20261110, 20261111, 20261112
Reproduce lesson 1
arcpuzzles generate public_eval_581f7754 --count 1 --seed 20261108 --test 1