1
0
Fork 0
This commit is contained in:
Jonathan Chan 2022-12-04 01:27:02 -05:00
parent e4c8c39753
commit 439885662e
2 changed files with 1022 additions and 0 deletions

1000
input/04.txt Normal file

File diff suppressed because it is too large Load Diff

22
src/04.rkt Normal file
View File

@ -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)