Please don’t rely on this Gitea instance being around forever. If any of your build scripts use my (kageru’s) projects hosted here, check my Github or IEW on Github for encoding projects. If you can’t find what you’re looking for there, tell me to migrate it.

Day13: Fix parseoutput

master
Arranun 3 years ago
parent 8df4b4c9c0
commit e5adad16ed

@ -13,7 +13,7 @@ main = do
let blocks =length $ M.filter(==2) step1Result
let result = runGame arcade M.empty
--let gameMap = createMap result [0..23] []
--let score = M.filterWithKey(\(V2 a b) _ -> a == -1 ) result
let score = M.filterWithKey(\(V2 a b) _ -> a == -1 ) result
--mapM putStrLn( map (map getSymbol) gameMap)
--putStrLn(show score)
putStrLn(show result)
@ -26,19 +26,19 @@ data Amplifier = Amplifier{ state :: [Int]
,output :: [Int]
} deriving Show
runGame :: Amplifier -> M.Map (V2 Int) Int -> [Int]
runGame :: Amplifier -> M.Map (V2 Int) Int -> M.Map (V2 Int) Int
runGame arcade gameM= do
let newArcade = step arcade [0]
let tiles = ((parseOutput M.empty (output newArcade)))
let newGameM = M.union tiles gameM
let blocks = length $ M.filter(== 2) newGameM
if blocks == 0
then output newArcade
if blocks == 0
then tiles
else runGame newArcade newGameM
parseOutput :: M.Map (V2 Int) Int -> [Int] -> M.Map (V2 Int) Int
parseOutput tiles (x:y:c:xs)
| length xs == 0 = tiles
| length xs == 0 = M.insert (V2 x y) c tiles
| length xs > 0 = parseOutput newtiles xs
where newtiles = M.insert (V2 x y) c tiles

Loading…
Cancel
Save