From 3ba214f6891712bdc9b264442cec3858f1abcce7 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Tue, 21 Dec 2021 12:02:51 +0200 Subject: Day 21 --- day21/main.hs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 day21/main.hs (limited to 'day21/main.hs') diff --git a/day21/main.hs b/day21/main.hs new file mode 100644 index 0000000..fa6926b --- /dev/null +++ b/day21/main.hs @@ -0,0 +1,20 @@ +module Main where + +import Debug.Trace (traceShow) +import Part1 +import Part2 +import Utils + +main :: IO () +main = do + contents <- getContents + let initialPositions@[p1Pos, p2Pos] = contents $> lines .> map (drop 28) .> map read :: [Int] + let initialState = makeState1 initialPositions [0, 0] 1 0 + print initialState + let (_, loserScore, dieRolledN) = simulate1 initialState 0 + print $ loserScore * dieRolledN + + let part2State = makeState2 (p1Pos, 0) (p2Pos, 0) + + -- this has a 50% chance of giving the right answer :D + print $ simulate2 0 part2State \ No newline at end of file -- cgit v1.3