projects
/
advent-of-code-20.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixing overlong lines
[advent-of-code-20.git]
/
advent11
/
src
/
advent11.hs
diff --git
a/advent11/src/advent11.hs
b/advent11/src/advent11.hs
index b56dc3df12a75893d6dd9db4a188a8ad23aab8fd..6fdfd6262c2c4f8414551b63d0f22a3496a9a558 100644
(file)
--- a/
advent11/src/advent11.hs
+++ b/
advent11/src/advent11.hs
@@
-85,7
+85,8
@@
neighbourhood seats here = S.intersection (M.keysSet seats) (neighbours here)
allNeighbourhoods :: Seats -> Neighbourhood
allNeighbourhoods seats = M.mapWithKey (\h _ -> neighbourhood seats h) seats
allNeighbourhoods :: Seats -> Neighbourhood
allNeighbourhoods seats = M.mapWithKey (\h _ -> neighbourhood seats h) seats
-occupiedNeighbours seats nbrs here = M.filter (== Occupied) $ M.restrictKeys seats (nbrs!here)
+occupiedNeighbours seats nbrs here = M.filter (== Occupied)
+ $ M.restrictKeys seats (nbrs!here)
onSightLine :: Position -> Direction -> Position -> Bool
onSightLine :: Position -> Direction -> Position -> Bool
@@
-106,15
+107,12
@@
closestInDirection seats here direction = take 1 sortedSeats
sortedSeats = sortOn (manhattan here) seatsInDirection
closestInSight :: Seats -> Position -> (S.Set Position)
sortedSeats = sortOn (manhattan here) seatsInDirection
closestInSight :: Seats -> Position -> (S.Set Position)
-closestInSight seats here = S.fromList $ concatMap (closestInDirection seats here) [d | d <- [Up .. UpLeft]]
+closestInSight seats here = S.fromList
+ $ concatMap (closestInDirection seats here) [d | d <- [Up .. UpLeft]]
allSightNeighbourhoods :: Seats -> Neighbourhood
allSightNeighbourhoods seats = M.mapWithKey (\h _ -> closestInSight seats h) seats
allSightNeighbourhoods :: Seats -> Neighbourhood
allSightNeighbourhoods seats = M.mapWithKey (\h _ -> closestInSight seats h) seats
--- occupiedInSight :: Seats -> Position -> Seats
--- occupiedInSight seats here = M.filter (== Occupied) $ M.restrictKeys seats $ closestInSight seats here
-
-
readGrid :: String -> (Seats, Position)
readGrid input = (seats, (maxR, maxC))
readGrid :: String -> (Seats, Position)
readGrid input = (seats, (maxR, maxC))