diff options
author | Laura Orvokki Kursula <lav@vampires.gay> | 2024-12-22 11:46:21 +0100 |
---|---|---|
committer | Laura Orvokki Kursula <lav@vampires.gay> | 2024-12-22 11:46:21 +0100 |
commit | eac86ee90ce6ab97a2d136be5339ac7c011836ac (patch) | |
tree | 491b4b498f17b2bbe5a0f03637d0f7bd713d8b4f | |
parent | 391f083fc61d3d173a3723ce238739efa3b759c3 (diff) | |
download | aoc2024-eac86ee90ce6ab97a2d136be5339ac7c011836ac.tar.gz aoc2024-eac86ee90ce6ab97a2d136be5339ac7c011836ac.zip |
22-1
-rw-r--r-- | 22-1.hs | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -0,0 +1,18 @@ +import Data.Bits (xor) +import Data.Function ((&)) + +mix :: Int -> Int -> Int +mix = xor + +prune :: Int -> Int +prune = (`mod` 16777216) + +mp :: Int -> Int -> Int +mp cur = prune . mix cur + +update :: Int -> Int +update x = mp x (x * 64) & \ y -> mp y (y `div` 32) & \ z -> mp z (z * 2048) + +main :: IO () +main = getContents + >>= print . sum . map ((!! 2000) . iterate update . read) . lines |