Refactor day 16
This commit is contained in:
@@ -9,10 +9,10 @@ getEnergized :: (Int, Int, Direction) -> Cavern -> [(Int, Int)]
|
||||
getEnergized (y0, x0, d) = toList . delete (y0, x0) . Data.Set.map (\ (y, x, _) -> (y, x)) . lightBeam (y0, x0) d empty
|
||||
|
||||
getStarts :: Cavern -> [(Int, Int, Direction)]
|
||||
getStarts c = [(y, 0, East) | y <- [1..(fst (snd $ bounds c))]]
|
||||
++ [(y, 1 + snd (snd $ bounds c), West) | y <- [1..(fst (snd $ bounds c))]]
|
||||
++ [(0, x, South) | x <- [1..(snd (snd $ bounds c))]]
|
||||
++ [(1 + fst (snd $ bounds c), x, North) | x <- [1..(snd (snd $ bounds c))]]
|
||||
getStarts c = [(y, 0, East) | y <- [1..fst (snd $ bounds c)]]
|
||||
++ [(y, 1 + snd (snd $ bounds c), West) | y <- [1..fst (snd $ bounds c)]]
|
||||
++ [(0, x, South) | x <- [1..snd (snd $ bounds c)]]
|
||||
++ [(1 + fst (snd $ bounds c), x, North) | x <- [1..snd (snd $ bounds c)]]
|
||||
|
||||
getMaxEnergized :: Cavern -> Int
|
||||
getMaxEnergized c = maximum (Prelude.map (\s -> length $ getEnergized s c) $ getStarts c)
|
||||
getMaxEnergized c = maximum $ Prelude.map (\s -> length $ getEnergized s c) $ getStarts c
|
||||
|
||||
Reference in New Issue
Block a user