card
トランプを分配する問題
ttp://ameblo.jp/programming/entry-10001721422.html
import Data.List trampf :: Int -> String -> [String] trampf n cs | n > length cs = repeat "" | otherwise = zipWith (++) as $ trampf n bs where as = heads n cs bs = drop n cs heads :: Int -> String -> [String] heads n = map ((\c->[c]).head).take n.tails main = do n <- getLine cs <- getLine print $ trampf (read n) cs
ちゃんと答えは出ます。