You are viewing a single comment's thread. Return to all comments →
haskell all test cases passed
newList :: [Int] -> [(Int,Int)] newList list = zip (evenList list) (oddList list) where oddList (x:y:xs) = y: oddList xs oddList _ =[] evenList list = oddList (1:list) solve :: [[Int]] -> [(Int,Int)] solve list = foldl step (head iList) iList where iList = map newList list step x@(i:is) y = (comp i y) ++ (step is y) step _ y = [] comp i@(x1,x2) ((y1,y2):ys) | x1 == y1 = if x2 < y2 then [(y1,x2)] else [(y1,y2)] | otherwise = comp i ys comp i _ = [] iToList ((x1,x2):xs) = (show x1) ++" "++ (show x2) ++ " " ++ (iToList xs) iToList _ = "" main = getContents >>= putStrLn.iToList.solve.tail.(map (map read)).(map words).lines
Seems like cookies are disabled on this browser, please enable them to open this website
Lists and GCD
You are viewing a single comment's thread. Return to all comments →
haskell all test cases passed