Created
March 10, 2022 13:44
-
-
Save takoeight0821/c5841ead6a75d1d443135c0aa2c2e5f3 to your computer and use it in GitHub Desktop.
センタイギアはおよそ128年間展開し続けられることを証明した。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env stack | |
-- stack script --resolver lts-18.26 | |
-- | 詳細は https://twitter.com/takoeight0821/status/1501899867249000448 | |
module Main where | |
import Data.Foldable | |
import Data.IORef | |
import Data.List | |
import Data.List.HT | |
alls = [[a, b, c, d, e, f, g, h] | a <- "0123", b <- "0123", c <- "0123", d <- "0123", e <- "0123", f <- "0123", g <- "0123", h <- "0123"] | |
valids = nubBy (\word1 word2 -> word2 `elem` [rotate n word1 | n <- [0 .. 7]]) alls | |
main = do | |
count <- newIORef (0 :: Int) | |
traverse_ (\valid -> modifyIORef count (+ 1) >> putStrLn valid) valids | |
print =<< readIORef count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment