Advent of Code solutions
at main 23 lines 615 B view raw
1import Control.Arrow 2import Data.Bits 3import Data.List 4import qualified Data.Map.Strict as Map 5 6prng :: Int -> Int 7prng = 8 id &&& (* 64) 9 >>> uncurry xor 10 >>> (`mod` 16777216) 11 >>> (id &&& (`div` 32)) 12 >>> uncurry xor 13 >>> (`mod` 16777216) 14 >>> (id &&& (* 2048)) 15 >>> uncurry xor 16 >>> (`mod` 16777216) 17 18prices rngs@(a : b : c : d : e : _) = Map.singleton (b - a, c - b, d - c, e - d) e : prices (drop 1 rngs) 19prices _ = [] 20 21answer = maximum . Map.unionsWith (+) . fmap (Map.unions . prices . fmap (`mod` 10) . take 2000 . iterate prng . read) . lines 22 23main = getContents >>= print . answer