SHARE
TWEET

Untitled

a guest May 19th, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Data.List
  2.  
  3. groupInto n [] = []
  4. groupInto n l  = take n l : groupInto n (drop n l)
  5.  
  6. doEveryOther fn (x:[])  = [x]
  7. doEveryOther fn []     = []
  8. doEveryOther fn (x:xs:xss) = x : fn xs : (doEveryOther fn xss)  
  9.  
  10. decrypt list n = concat . transpose . doEveryOther reverse $ groupInto n list
  11.  
  12. main = do getContents >>= mapM putStrLn . map (\(x:xs) -> decrypt (head xs) (read x)) . groupInto 2 . takeWhile (/= "0") . lines
RAW Paste Data
Challenge yourself this year...
Learn something new in 2017
Top