blob: d65f0ab62b63f0f46d1c84f6ec6e787dc4a11f88 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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)
|