Day 4
This commit is contained in:
parent
e4c8c39753
commit
439885662e
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,22 @@
|
|||
#lang racket
|
||||
|
||||
(require "../lib.rkt")
|
||||
|
||||
(define input
|
||||
(for/list ([assn (problem-input 4)])
|
||||
(map string->number (regexp-match* #px"\\d+" assn))))
|
||||
|
||||
(define (contains? l1 r1 l2 r2)
|
||||
(or (and (<= l1 l2) (>= r1 r2))
|
||||
(and (<= l2 l1) (>= r2 r1))))
|
||||
|
||||
(define (overlaps? l1 r1 l2 r2)
|
||||
(not (or (> l2 r1) (> l1 r2))))
|
||||
|
||||
(define part1
|
||||
(count (∂ apply contains?) input))
|
||||
|
||||
(define part2
|
||||
(count (∂ apply overlaps?) input))
|
||||
|
||||
(show-solution part1 part2)
|
Loading…
Reference in New Issue