diff --git a/day1/solution.rkt b/day1/solution.rkt index 0b2a53e..84c2547 100644 --- a/day1/solution.rkt +++ b/day1/solution.rkt @@ -2,9 +2,10 @@ (provide (all-defined-out)) -(require qi) +(require qi + (prefix-in list: racket/list)) -(define-flow partn (~>> (-< drop-right drop) (count <))) +(define-flow partn (~>> (-< drop-right drop) (list:count <))) (define-flow part1* (partn 1)) (define-flow part1 (~> file->list part1*)) diff --git a/day10/solution.rkt b/day10/solution.rkt index 11a906e..4d2dec2 100644 --- a/day10/solution.rkt +++ b/day10/solution.rkt @@ -32,16 +32,18 @@ (define checker-scores (hash #\) 3 #\] 57 #\} 1197 #\> 25137)) +(define checker (make-checker closers)) + (define-flow part1* (~> sep - (amp (make-checker closers)) + (amp checker) (pass char?) (amp (hash-ref checker-scores _)) +)) (define-flow part1 (~> file->lines part1*)) (define-flow incomplete? - (~> (make-checker closers) + (~> checker (if (or char? null?) ground _))) (define complete-scores (hash #\) 1 #\] 2 #\} 3 #\> 4)) diff --git a/day11/solution.rkt b/day11/solution.rkt index f5afd63..7c19535 100644 --- a/day11/solution.rkt +++ b/day11/solution.rkt @@ -81,7 +81,7 @@ (define (stepN n) (flow (feedback n step))) (define-flow part1* - (~> (stepN 100) 2>)) + (~> (esc (stepN 100)) 2>)) (define-flow part1 (~> file->grid part1*)) (define-flow part2* diff --git a/day13/solution.rkt b/day13/solution.rkt index 494e22a..b8c07a0 100644 --- a/day13/solution.rkt +++ b/day13/solution.rkt @@ -35,11 +35,11 @@ (match instruction [`(x ,n) (~> (points) - (set-map (flow (~> (-< x y) (update-first n) cons))) + (set-map (flow (~> (-< x y) (esc (update-first n)) cons))) sep set)] [`(y ,n) (~> (points) - (set-map (flow (~> (-< y x) (update-first n) X cons))) + (set-map (flow (~> (-< y x) (esc (update-first n)) X cons))) sep set)])) (define (fold instructions points) diff --git a/day16/solution.rkt b/day16/solution.rkt index f321d7f..87a0b83 100644 --- a/day16/solution.rkt +++ b/day16/solution.rkt @@ -99,7 +99,7 @@ (define-values (data offset) (for/fold ([data null] [offset (+ 11 1 start)]) - ([_ (in-range length)]) + ([_ignore (in-range length)]) (~>> (offset) (decode packet-string) (== (cons data) _)))) diff --git a/day20/solution.rkt b/day20/solution.rkt index d3766e1..aae8275 100644 --- a/day20/solution.rkt +++ b/day20/solution.rkt @@ -2,7 +2,8 @@ (provide (all-defined-out)) -(require qi) +(require qi + (prefix-in list: racket/list)) (define-flow light? (or (eq? 1) (eq? #\#))) (define-flow dark? (or (eq? 0) (eq? #\.))) @@ -102,7 +103,7 @@ (sub1 ym) (add1 yM)))) (define-flow count-light - (~>> hash-values (count light?))) + (~>> hash-values (list:count light?))) (define (count-light-n n) (flow (~>> (enhance-image-n n) 1> (ε display-image count-light)))) diff --git a/day3/solution.rkt b/day3/solution.rkt index ecc3919..e8dd1b2 100644 --- a/day3/solution.rkt +++ b/day3/solution.rkt @@ -62,7 +62,7 @@ (define-flow (fieldth field) (clos (~> X list-ref))) (define (criterion-solver selector rows) (define (filterc field criterion rows) - (define-flow matches (~> (fieldth field) (= criterion))) + (define-flow matches (~> (esc (fieldth field)) (= criterion))) (filter matches rows)) ;; we cannot name this loop, because qi's flow has a loop syntactic form that ;; confuses our intent. diff --git a/day4/solution.rkt b/day4/solution.rkt index 216df11..13e0923 100644 --- a/day4/solution.rkt +++ b/day4/solution.rkt @@ -58,7 +58,7 @@ (hash-ref n #f) (if _ update-board-board - (const b)))) + (gen b)))) (define (find-first-winner moves boards) (let loop ([boards boards] diff --git a/day5/solution.rkt b/day5/solution.rkt index 797d782..e261dbd 100644 --- a/day5/solution.rkt +++ b/day5/solution.rkt @@ -3,6 +3,7 @@ (provide (all-defined-out)) (require qi + (prefix-in list: racket/list) "../common.rkt") (struct point [x y] #:transparent) @@ -63,7 +64,7 @@ collect (group-by identity) (map length) - (count (flow (>= 2))))) + (list:count (flow (>= 2))))) (define-flow part1* (~>> list->segments (filter segment-cardinal?) count-overlaps)) (define-flow part1 (~> (file->list read-ignore-comma) part1*)) diff --git a/day8/solution.rkt b/day8/solution.rkt index 1382f72..14e9114 100644 --- a/day8/solution.rkt +++ b/day8/solution.rkt @@ -96,7 +96,7 @@ (remove-duplicates (find-pats-matching-digits pats '(0 6 9)))) ;; 3 (match-define-values (`(,six) zero-nine) - (partition (flow (~>> (subset? one) not)) zero-six-nine)) + (partition (flow (not (subset? one _))) zero-six-nine)) ;; 4 (define C (set-first (set-subtract one six))) ;; 5 diff --git a/day9/solution.rkt b/day9/solution.rkt index 1a3c212..62b8a07 100644 --- a/day9/solution.rkt +++ b/day9/solution.rkt @@ -51,7 +51,7 @@ (if (and% (not (set-member? seen _)) (and (< height _) (not (>= 9)))) (~> (-< cons (~>> 1> (set-add seen))) - (basin-size* grid) + (esc (basin-size* grid)) (== (+ size) _)) (gen size seen)))))