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.

Day15: Part 2 works

master
Arranun 3 years ago
parent 6e36014987
commit ea5b4b48de

@ -11,8 +11,18 @@ main = do
let resultRobots = (runRobot robot )
let winRobots = filter(\(Robot br pts pos dir) -> elem 2 (map(\(p,c) -> c) pts))resultRobots
let winRobotsLength = map(\(Robot br pts pos dir) -> length (filter(\(p,c) -> c == 1)pts))winRobots
let winRobot = (map(\(Robot br pts pos dir) -> Robot br [] pos 1) winRobots) !! 0
let part2Robots = (runRobot winRobot)
let part2Length = map(\(Robot br pts pos dir) -> length (filter(\(p,c) -> c == 1)pts))part2Robots
let endPoints = foldl (++) [] (map(\(Robot br pts pos dir) -> pts) resultRobots)
let yMin = List.minimum (map(\((x,y),c) -> y) endPoints)
let yMax = List.maximum (map(\((x,y),c) -> y) endPoints)
let posEndPoints = map(\((a,b),c)-> ((a+30,b),c)) endPoints
let ship = createMap posEndPoints (reverse [yMin-1..yMax]) []
mapM putStrLn(map show ship)
putStrLn(show $ length endPoints)
putStrLn(show winRobotsLength)
putStrLn ("ELL")
putStrLn(show $ List.maximum( part2Length))
data Amplifier = Amplifier{ state :: [Int]
,index :: Int
@ -72,12 +82,10 @@ move (x,y) direction
getNextMove :: Robot -> [Int]
getNextMove (Robot brain points position direction)
|length points == 300 = []
|length points > 0 && (snd $ last points) == 2 = []
|otherwise = do
filterMoves (Robot brain points position direction) [1,2,3,4]
filterMoves :: Robot -> [Int] -> [Int]
filterMoves robot moves = filter(\x -> checkVisit robot x && checkWall robot x) moves

Loading…
Cancel
Save