Last active
August 29, 2015 14:02
-
-
Save J0J0/37cb360c775b35246857 to your computer and use it in GitHub Desktop.
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
import System.Environment (getArgs) | |
data Dir = U | R deriving(Show) | |
type Link = [Dir] | |
shuf :: Link -> Int -> Int -> [Link] | |
shuf ds 0 0 = [ds] | |
shuf ds 0 q = shuf (R:ds) 0 (q-1) | |
shuf ds p 0 = shuf (U:ds) (p-1) 0 | |
shuf ds p q = | |
up ++ right | |
where | |
up = shuf (U:ds) (p-1) q | |
right = shuf (R:ds) p (q-1) | |
print_permute ylen xlen = do | |
sequence_ $ map print $ shuf [] ylen xlen | |
main = do | |
args <- getArgs | |
case args of | |
[xlen,ylen] -> print_permute (read ylen) (read xlen) | |
_ -> putStrLn "need exactly two arguments" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment