You are viewing a single comment's thread. Return to all comments →
Haskell
import Data.List (intercalate) gcdl :: [Int] -> [Int] -> [Int] gcdl [] xs = [] gcdl xs [] = [] gcdl xs@(x : xe : xtail) ys@(y : ye : ytail) | x < y = gcdl xtail ys | x > y = gcdl xs ytail | otherwise = x : min xe ye : gcdl xtail ytail main = do contents <- getContents let xss = [map read $ words l | l <- tail $ lines contents] putStrLn $ intercalate " " $ map show $ foldl1 gcdl xss
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