Skip to content

Instantly share code, notes, and snippets.

@takoeight0821
Created March 10, 2022 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takoeight0821/c5841ead6a75d1d443135c0aa2c2e5f3 to your computer and use it in GitHub Desktop.
Save takoeight0821/c5841ead6a75d1d443135c0aa2c2e5f3 to your computer and use it in GitHub Desktop.
センタイギアはおよそ128年間展開し続けられることを証明した。
#!/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