Update all new Tasks

This commit is contained in:
Ingy döt Net 2015-02-20 09:02:09 -05:00
parent 00a190b0a6
commit 91df62d461
5697 changed files with 93386 additions and 804 deletions

View file

@ -0,0 +1,19 @@
import qualified Data.List as L
import qualified Data.Maybe as M
table :: String
table = ['a'..'z']
encode :: String -> [Int]
encode = snd . L.mapAccumL f table
where
f t s = ((s : L.delete s t), M.fromJust (L.elemIndex s t))
decode :: [Int] -> String
decode = snd . L.mapAccumL f table
where
f t i = let s = (t !! i) in ((s : L.delete s t), s)
main :: IO ()
main = mapM_ (\s -> let t@(e, _) = (encode s, decode e) in print t)
["broood", "bananaaa", "hiphophiphop"]