aboutsummaryrefslogtreecommitdiffstats
path: root/day21/main.hs
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2021-12-21 12:02:51 +0200
committerJan Tuomi <jans.tuomi@gmail.com>2021-12-21 13:46:12 +0200
commit3ba214f6891712bdc9b264442cec3858f1abcce7 (patch)
tree0d33e59d831975c1b8729ce4f488f1e4fc743165 /day21/main.hs
parent8cf112cad7c0a52676a834ec3ac77f3006031c87 (diff)
Day 21
Diffstat (limited to 'day21/main.hs')
-rw-r--r--day21/main.hs20
1 files changed, 20 insertions, 0 deletions
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