Add 2020 day 25 p1

This commit is contained in:
Xavier Morel
2021-01-10 10:47:08 +01:00
parent e06aa0990d
commit d040b97bc8
2 changed files with 18 additions and 2 deletions

View File

@@ -0,0 +1,2 @@
3418282
8719412

View File

@@ -1,6 +1,20 @@
module Y2020.Day25 (y20day25) where
doTransform :: Int -> Int -> Int
doTransform subjNumber n = rem (n * subjNumber) 20201227
getLoopSize :: Int -> Int
getLoopSize targetPK = length $ takeWhile (/= targetPK) $ iterate (doTransform 7) 1
transformNtimes :: Int -> Int -> Int
transformNtimes subjNumber loopSize = head $ drop loopSize $ iterate (doTransform subjNumber) 1
y20day25 :: [String] -> (String, String)
y20day25 input = (part1, part2)
where part1 = "WIP"
part2 = "WIP"
where part1 = show $ transformNtimes doorpk cardls
part2 = show $ "WIP"
input' = map read input :: [Int]
doorpk = input' !! 0
cardpk = input' !! 1
-- doorls = getLoopSize doorpk
cardls = getLoopSize cardpk