Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Control.Monad
- import Text.Printf
- parenthsCombinations :: Word -> [String]
- parenthsCombinations 0 = [""]
- parenthsCombinations n =
- concatMap (uncurry $ liftM2 $ printf "(%s)%s") $
- zip combinations (reverse combinations)
- where combinations = map parenthsCombinations [n - 1, n - 2 .. 0]
- main = readLn >>= putStr . concatMap (++ "\n") . parenthsCombinations
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement