You are viewing a single comment's thread. Return to all comments →
indexed :: [a] -> [(Int,a)] indexed xs = go 0 xs where go i (a:as) = (i,a) : go (i+1) as go _ _ = [] solve :: (Ord a) => [(Int,a)] -> [a] solve x = let evenList = foldr (\(i,v) acc -> if (even i) then v:acc else acc) [] x oddList = foldr (\(i,v) acc -> if (odd i) then v:acc else acc ) [] x in concat [ [a,b] | (a,b) <- (flip zip evenList oddList) ] main = interact $ unlines . map solve . map indexed . tail . words
Seems like cookies are disabled on this browser, please enable them to open this website
String-o-Permute
You are viewing a single comment's thread. Return to all comments →