do
content <- input 4
let run = Aoc.run content
run (pure 456) (length . strategy fullOverlap)
run (pure 808) (length . strategy overlap)
where
strategy a = filter (uncurry a . parsePair) . lines
type Range = (Int, Int)
type Pair = (Range, Range)
cmp x y || cmp y x
where
cmp a b = fst a <= fst b && snd a >= snd b
cmp a b || cmp b a
where
cmp a b = fst a <= fst b && snd a >= fst b
bimap read (negate . read) . break (=='-')
bimap parseRange (parseRange . drop 1) . break (==',')