diff options
author | tomsmeding <tom.smeding@gmail.com> | 2019-12-22 08:39:35 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2019-12-22 08:39:35 +0100 |
commit | 348f30a95b33908777e1b9ca4f1490cf417d195c (patch) | |
tree | 7abd1e88237e9964bc65da4fc512f4cf54aa0278 /2019/21.hs | |
parent | dc2eea09900d0baa73768ff205d86690a92964c9 (diff) |
Day 21
Diffstat (limited to '2019/21.hs')
-rw-r--r-- | 2019/21.hs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/2019/21.hs b/2019/21.hs new file mode 100644 index 0000000..d65f0ab --- /dev/null +++ b/2019/21.hs @@ -0,0 +1,33 @@ +module Main where + +import Data.Char + +import Input +import IntCode + + +main :: IO () +main = do + program <- parse . head <$> getInput 21 + + let springcode1 = "NOT A T\nNOT B J\nOR J T\nNOT C J\nOR T J\nAND D J\nWALK\n" + + -- let loop cont inp = + -- case runContinue cont inp of + -- Left (cont', out) -> do + -- putStr (map (chr . fromIntegral) out) + -- line <- map (fromIntegral . ord) <$> getLine + -- loop cont' (line ++ [10]) + -- Right (_, out) -> + -- putStr (map (chr . fromIntegral) out) + + -- loop (initialContinuation program) [] + + let output1 = snd (run program (map (fromIntegral . ord) springcode1)) + print (last output1) + + let springcode2 = "NOT A T\nNOT B J\nOR J T\nNOT C J\nOR T J\nAND D J\nNOT E T\nNOT T T\nOR H T\nAND T J\nRUN\n" + + let output2 = snd (run program (map (fromIntegral . ord) springcode2)) + -- putStr (map (chr . fromIntegral) output2) + print (last output2) |