Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 93d2369

Browse files
committed
some cleanup of day 21
1 parent 2c8a29f commit 93d2369

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

‎src/AOC2017/Day21.hs‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
module AOC2017.Day21 (day21a, day21b) where
44

55
import AOC2017.Types (Challenge)
6-
import AOC2017.Util
7-
import Control.Lens
8-
import Data.List
9-
import Data.List.Split
6+
import AOC2017.Util ((!!!), strip)
7+
import Control.Lens (over, Traversal')
8+
import Data.List (transpose)
9+
import Data.List.Split (chunksOf, splitOn)
1010
import qualified Data.Map as M
11-
import qualified Data.Vector as V
12-
import qualified Linear as L
1311

1412
type Grid = [[Bool]]
1513

@@ -37,15 +35,16 @@ parse = M.unions . map (M.fromList . parseLine) . lines
3735
where
3836
gridIn = fmap (== '#') <$> xs
3937
gridOut = fmap (== '#') <$> ys
38+
parseLine _ = error "No parse"
4039

4140
-- | A traversal over subgrids of a grid
4241
subgrids :: Int -> Traversal' Grid Grid
43-
subgrids n f = fmap joinGrid . (traverse . traverse) f . splitGrid n
42+
subgrids n f = fmap joinGrid . (traverse . traverse) f . splitGrid
4443
where
45-
splitGrid :: Int->Grid -> [[Grid]]
46-
splitGrid n = transpose
47-
. map (map transpose . chunksOf n . transpose)
48-
. chunksOf n
44+
splitGrid :: Grid -> [[Grid]]
45+
splitGrid = transpose
46+
. map (map transpose . chunksOf n . transpose)
47+
. chunksOf n
4948
joinGrid :: [[Grid]] -> Grid
5049
joinGrid = transpose . concatMap (transpose . concat)
5150

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /