do
content <- input 6
let run = Aoc.run content
run (pure 1282) $ calibrate 4
run (pure 3513) $ calibrate 14
go 0
where
go i xs = case packetValidation (take packetSize xs) of
(Calibrate c) -> go (i + c) (drop c xs)
Ok -> i + packetSize
data Marker = Calibrate Int | Ok
go 0 []
where
go i _ [] = Ok
go i set (x:xs) = case elemIndex x set of
(Just c) -> Calibrate (c + 1)
Nothing -> go (i + 1) (set ++ [x]) xs