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 61899d4

Browse files
committed
further cleaning of day 21
1 parent 93d2369 commit 61899d4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

‎src/AOC2017/Day21.hs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ type Rule = M.Map Grid Grid
1616
-- | All 8 symmetries (elements of D8)
1717
--
1818
-- Generated by r, r^2, r^3, r^4, and flip times all of those
19+
--
20+
-- Thanks to https://en.wikipedia.org/wiki/Dihedral_group_of_order_8
1921
symmetries :: Grid -> [Grid]
2022
symmetries g = rots ++ (mirror <$> rots)
2123
where
@@ -55,12 +57,11 @@ step r g = over (subgrids n) (r M.!) g
5557
| length g `mod` 3 == 0 = 3
5658
| otherwise = error "hello there"
5759

58-
grid0 :: Grid
59-
grid0 = map (== '#') <$> [".#.","..#","###"]
60-
6160
day21 :: Int -> Rule -> Int
6261
day21 n r = length . filter id . concat
6362
$ iterate (step r) grid0 !!! n
63+
where
64+
grid0 = map (== '#') <$> [".#.","..#","###"]
6465

6566
day21a :: Challenge
6667
day21a = show . day21 5 . parse

0 commit comments

Comments
(0)

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