From eac86ee90ce6ab97a2d136be5339ac7c011836ac Mon Sep 17 00:00:00 2001 From: Laura Orvokki Kursula Date: Sun, 22 Dec 2024 11:46:21 +0100 Subject: 22-1 --- 22-1.hs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 22-1.hs diff --git a/22-1.hs b/22-1.hs new file mode 100644 index 0000000..f8d7117 --- /dev/null +++ b/22-1.hs @@ -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 -- cgit v1.2.3