diff options
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) |