We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 93d2369 commit 61899d4Copy full SHA for 61899d4
src/AOC2017/Day21.hs
@@ -16,6 +16,8 @@ type Rule = M.Map Grid Grid
16
-- | All 8 symmetries (elements of D8)
17
--
18
-- 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
21
symmetries :: Grid -> [Grid]
22
symmetries g = rots ++ (mirror <$> rots)
23
where
@@ -55,12 +57,11 @@ step r g = over (subgrids n) (r M.!) g
55
57
| length g `mod` 3 == 0 = 3
56
58
| otherwise = error "hello there"
59
-grid0 :: Grid
-grid0 = map (== '#') <$> [".#.","..#","###"]
60
-
61
day21 :: Int -> Rule -> Int
62
day21 n r = length . filter id . concat
63
$ iterate (step r) grid0 !!! n
+ where
64
+ grid0 = map (== '#') <$> [".#.","..#","###"]
65
66
day21a :: Challenge
67
day21a = show . day21 5 . parse
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments