Day 13: Move readIntcode to Intcode.hs
This commit is contained in:
parent
5caa4b44db
commit
dd8dfd20d7
|
@ -2,13 +2,11 @@ module Helpers
|
||||||
( v2x
|
( v2x
|
||||||
, v2y
|
, v2y
|
||||||
, drawMap
|
, drawMap
|
||||||
, readIntcode
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.List
|
import Data.List
|
||||||
import Data.List.Split
|
import Data.List.Split
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import qualified Data.Vector as V
|
|
||||||
import Linear.V2
|
import Linear.V2
|
||||||
|
|
||||||
v2x :: V2 a -> a
|
v2x :: V2 a -> a
|
||||||
|
@ -40,5 +38,3 @@ drawMap dict m =
|
||||||
where
|
where
|
||||||
(x1, y1, x2, y2) = getBounds m
|
(x1, y1, x2, y2) = getBounds m
|
||||||
|
|
||||||
readIntcode :: String -> V.Vector Integer
|
|
||||||
readIntcode = V.fromList . concatMap (map read . splitOn ",") . lines
|
|
||||||
|
|
|
@ -5,11 +5,13 @@ module Intcode
|
||||||
, defaultTM
|
, defaultTM
|
||||||
, TMOutState(Continue, AwaitInput, Halt)
|
, TMOutState(Continue, AwaitInput, Halt)
|
||||||
, execSteps
|
, execSteps
|
||||||
|
, readIntcode
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.DeepSeq as DeepSeq
|
import Control.DeepSeq as DeepSeq
|
||||||
import Data.Char
|
import Data.Char
|
||||||
import Data.List as L
|
import Data.List as L
|
||||||
|
import Data.List.Split
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Data.Vector as V hiding
|
import Data.Vector as V hiding
|
||||||
( (++)
|
( (++)
|
||||||
|
@ -47,6 +49,9 @@ data TuringMachine =
|
||||||
}
|
}
|
||||||
deriving (Show)
|
deriving (Show)
|
||||||
|
|
||||||
|
readIntcode :: String -> V.Vector Integer
|
||||||
|
readIntcode = V.fromList . concatMap (map read . splitOn ",") . lines
|
||||||
|
|
||||||
defaultTM :: Maybe (Int, Integer) -> Vector Integer -> TuringMachine
|
defaultTM :: Maybe (Int, Integer) -> Vector Integer -> TuringMachine
|
||||||
defaultTM replacement t =
|
defaultTM replacement t =
|
||||||
TM
|
TM
|
||||||
|
|
Loading…
Reference in New Issue
Block a user