22 lines
562 B
Haskell
Raw Normal View History

2025-12-09 10:27:50 +00:00
module Puzzles.Day9 (puzzle) where
import Pre
2025-12-09 10:47:32 +00:00
import Data.Text.Lazy qualified as TL
2025-12-09 10:27:50 +00:00
puzzle :: Puzzle
puzzle =
Puzzle
{ number = 9
2025-12-09 10:47:32 +00:00
, parser = const $ (V2 @Int <$> decimal <* single ',' <*> decimal) `sepEndBy1` newline
2025-12-09 10:27:50 +00:00
, parts =
2025-12-09 10:47:32 +00:00
[ TL.show
. maximum
. fmap ((\(V2 x y) -> x * y) . (+ 1) . fmap abs . uncurry (-))
2025-12-09 13:34:48 +00:00
. fromMaybe (error "input too small")
2025-12-09 10:47:32 +00:00
. nonEmpty
. allUnorderedPairs False
2025-12-09 10:27:50 +00:00
]
, extraTests = mempty
}