345d628347
We enterprise now
34 lines
795 B
Haskell
34 lines
795 B
Haskell
module Main where
|
|
|
|
import Intcode
|
|
import Data.List.Split
|
|
import qualified Data.Vector as V
|
|
|
|
main :: IO ()
|
|
main = do
|
|
content <- readFile "input"
|
|
let program = V.fromList $ concatMap (map read . splitOn ",") (lines content)
|
|
let run x =
|
|
runIntcode
|
|
(TM
|
|
{ tape = tapePreprocess program
|
|
, pointer = 0
|
|
, pointerOffset = 0
|
|
, output = []
|
|
, input = [x]
|
|
, state = Continue
|
|
})
|
|
let out1 = output $ run 1
|
|
let out2 = output $ run 2
|
|
print $
|
|
concat
|
|
["Part 1: " ++ show a ++ ", Part 2: " ++ show b | a <- out1, b <- out2]
|
|
|
|
runIntcode :: TuringMachine -> TuringMachine
|
|
runIntcode tm =
|
|
case state tmNew of
|
|
Continue -> runIntcode tmNew
|
|
_ -> tmNew
|
|
where
|
|
tmNew = step tm
|