Day 13: Move readIntcode to Intcode.hs

This commit is contained in:
shu 2019-12-13 19:56:08 +01:00
parent 5caa4b44db
commit dd8dfd20d7
2 changed files with 5 additions and 4 deletions

View File

@ -2,13 +2,11 @@ module Helpers
( v2x
, v2y
, drawMap
, readIntcode
) where
import Data.List
import Data.List.Split
import qualified Data.Map as M
import qualified Data.Vector as V
import Linear.V2
v2x :: V2 a -> a
@ -40,5 +38,3 @@ drawMap dict m =
where
(x1, y1, x2, y2) = getBounds m
readIntcode :: String -> V.Vector Integer
readIntcode = V.fromList . concatMap (map read . splitOn ",") . lines

View File

@ -5,11 +5,13 @@ module Intcode
, defaultTM
, TMOutState(Continue, AwaitInput, Halt)
, execSteps
, readIntcode
) where
import Control.DeepSeq as DeepSeq
import Data.Char
import Data.List as L
import Data.List.Split
import Data.Maybe
import Data.Vector as V hiding
( (++)
@ -47,6 +49,9 @@ data TuringMachine =
}
deriving (Show)
readIntcode :: String -> V.Vector Integer
readIntcode = V.fromList . concatMap (map read . splitOn ",") . lines
defaultTM :: Maybe (Int, Integer) -> Vector Integer -> TuringMachine
defaultTM replacement t =
TM