|
Sat, Dec. 22nd, 2012, 12:59 am
Sat, Dec. 22nd, 2012, 02:23 am (Anonymous)
Вот набыдлокодил.
import Control.Applicative( (<$>), (<*>) ) import System( getArgs )
main = do args <- getArgs >>= \args -> return ( -1 + read (head args) :: Int , last args ) result <- readFile (snd args) >>= (\string -> return $ unlines $ combination (fst args) (words string)) putStr result where combination count what = combination' count what $ (++) <$> what where combination' 0 combs _ = combs combination' count combined combiner = combination' (count - 1) (combiner <*> combined) combiner
$ echo "a b c" > alph $ ./check 3 alph aaa aab aac aba abb abc aca acb acc baa bab bac bba bbb bbc bca bcb bcc caa cab cac cba cbb cbc cca ccb ccc Sat, Dec. 22nd, 2012, 02:25 am (Anonymous)
ff http://pastebin.com/LPZWzpJt
2000^12 = 4.09600 × 10^39 несколько больше, чем девять миллиардов Sat, Dec. 22nd, 2012, 03:04 pm (Anonymous)
Хули, взял, да и запаралелил вычесления. |