Skip to content

Instantly share code, notes, and snippets.

@akanehara
Created December 27, 2012 09:38
Show Gist options
  • Save akanehara/4386918 to your computer and use it in GitHub Desktop.
Save akanehara/4386918 to your computer and use it in GitHub Desktop.
漫画「ムーたち」で、ムー夫のママがドアノブの前で動かなくなってしまうシーンをHaskellで書くとたぶんこう
module Main (main) where
main :: IO ()
main = do
let fingersPermutation = permutation fingers
mapM_ (putStrLn . show) fingersPermutation
putStrLn $ show $ length fingersPermutation
fingers :: [Int]
fingers = [1..5]
permutation :: Eq a => [a] -> [[a]]
permutation fs = go [] fs
where
go path [] = [reverse path]
go path rest = rest >>= \f -> go (f : path) [ x | x <- rest, x /= f]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment