summaryrefslogtreecommitdiff
path: root/2019/2.hs
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2019-12-05 12:00:37 +0100
committertomsmeding <tom.smeding@gmail.com>2019-12-05 12:03:10 +0100
commit2635d4b3f0db38e5399b0945f114c4775ea413fd (patch)
treec386639d905b94bbde97f5ccced2f05e0e0caf41 /2019/2.hs
parent3be84c5542e3392bbcf5cfe3e229fdcec4520235 (diff)
Day 2 in Haskell with IntCode module
Diffstat (limited to '2019/2.hs')
-rw-r--r--2019/2.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/2019/2.hs b/2019/2.hs
new file mode 100644
index 0000000..51ecf12
--- /dev/null
+++ b/2019/2.hs
@@ -0,0 +1,16 @@
+module Main where
+
+import Control.Monad
+
+import Input
+import IntCode
+
+
+main :: IO ()
+main = do
+ initMem <- parse . head <$> getInput 2
+ let set12 a b mem = head mem : a : b : drop 3 mem
+ run' a b = fst (run (set12 a b initMem) []) !! 0
+ print (run' 12 2)
+ forM_ [0..99] $ \a -> forM_ [0..99] $ \b ->
+ when (run' a b == 19690720) $ print (100 * a + b)