Day 11: Improve bounds
Some day lenses, maybe, when I read up on them
This commit is contained in:
parent
c94ec57f9f
commit
b8e7d09015
|
@ -6,6 +6,7 @@ import qualified Data.Map.Strict as M
|
|||
import qualified Data.Vector as V
|
||||
import Intcode
|
||||
import Linear.V2
|
||||
import Control.Lens
|
||||
|
||||
data RoboState =
|
||||
RoboState
|
||||
|
@ -31,7 +32,7 @@ main = do
|
|||
}
|
||||
, RoboState {hull = M.empty, position = V2 0 0, direction = V2 0 1})
|
||||
print $ length $ hull $ snd $ run 0
|
||||
putStrLn $ drawHull $ hull $ snd $ run 1
|
||||
putStrLn $ drawHull $ M.filter (==1) $ hull $ snd $ run 1
|
||||
|
||||
drawHull :: M.Map (V2 Int) Integer -> String
|
||||
drawHull m =
|
||||
|
@ -39,12 +40,12 @@ drawHull m =
|
|||
transpose $
|
||||
map reverse $
|
||||
chunksOf
|
||||
60
|
||||
10
|
||||
[ case M.findWithDefault 0 (V2 x y) m of
|
||||
1 -> '•'
|
||||
_ -> ' '
|
||||
| x <- [(-10) .. 49]
|
||||
, y <- [(-10) .. 49]
|
||||
| x <- [(-5) .. 44]
|
||||
, y <- [(-5) .. 4]
|
||||
]
|
||||
|
||||
runIntcode :: (TuringMachine, RoboState) -> (TuringMachine, RoboState)
|
||||
|
|
Loading…
Reference in New Issue