day 4: genious solution
This commit is contained in:
parent
00244a4f1c
commit
60425f6658
10
4.rkt
10
4.rkt
|
@ -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))])
|
||||||
|
|
Loading…
Reference in New Issue