23 lines
561 B
Racket
23 lines
561 B
Racket
#lang curly-fn racket
|
|
|
|
(require "scripts/aoc.rkt")
|
|
|
|
;; solution for day 4
|
|
|
|
(define (part1 input)
|
|
(count #{member (apply is:union %) %} input))
|
|
|
|
(define (part2 input)
|
|
(count #{is:get-integer (apply is:intersect %)} input))
|
|
|
|
(define (parse fname)
|
|
(for/list ([line (in-list (file->lines fname))])
|
|
(map #{~>> (string-split % "-") (map string->number) (apply is:make-range)}
|
|
(string-split line ","))))
|
|
|
|
(module+ main
|
|
(define input (parse "inputs/4"))
|
|
(answer 4 1 (time (part1 input)))
|
|
(answer 4 2 (time (part2 input)))
|
|
(displayln "meow"))
|