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 ;; solution for day 4
(define (part1 input) (define (part1 input)
(for*/sum ([line (in-list input)] (count #{member (apply is:union %) %} input))
[u (in-value (apply is:union line))]
#:when (member u line))
1))
(define (part2 input) (define (part2 input)
(for*/sum ([line (in-list input)] (count #{is:get-integer (apply is:intersect %)} input))
[i (in-value (apply is:intersect line))]
#:unless (zero? (is:count i)))
1))
(define (parse fname) (define (parse fname)
(for/list ([line (in-list (file->lines fname))]) (for/list ([line (in-list (file->lines fname))])