day 4: genious solution

This commit is contained in:
xenia 2022-12-04 00:32:38 -05:00
parent 00244a4f1c
commit 60425f6658
1 changed files with 2 additions and 8 deletions

10
4.rkt
View File

@ -5,16 +5,10 @@
;; solution for day 4
(define (part1 input)
(for*/sum ([line (in-list input)]
[u (in-value (apply is:union line))]
#:when (member u line))
1))
(count #{member (apply is:union %) %} input))
(define (part2 input)
(for*/sum ([line (in-list input)]
[i (in-value (apply is:intersect line))]
#:unless (zero? (is:count i)))
1))
(count #{is:get-integer (apply is:intersect %)} input))
(define (parse fname)
(for/list ([line (in-list (file->lines fname))])