mirror of
https://github.com/mx42/adventofcode.git
synced 2026-01-14 05:49:52 +01:00
Add 2020 day 25 p1
This commit is contained in:
2
haskellAoC/inputs/2020/25
Normal file
2
haskellAoC/inputs/2020/25
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
3418282
|
||||||
|
8719412
|
||||||
@@ -1,6 +1,20 @@
|
|||||||
module Y2020.Day25 (y20day25) where
|
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 :: [String] -> (String, String)
|
||||||
y20day25 input = (part1, part2)
|
y20day25 input = (part1, part2)
|
||||||
where part1 = "WIP"
|
where part1 = show $ transformNtimes doorpk cardls
|
||||||
part2 = "WIP"
|
part2 = show $ "WIP"
|
||||||
|
input' = map read input :: [Int]
|
||||||
|
doorpk = input' !! 0
|
||||||
|
cardpk = input' !! 1
|
||||||
|
-- doorls = getLoopSize doorpk
|
||||||
|
cardls = getLoopSize cardpk
|
||||||
|
|||||||
Reference in New Issue
Block a user