Skip to content

Instantly share code, notes, and snippets.

@jhedev
Created May 29, 2015 11:23
Show Gist options
  • Save jhedev/87b2e5d86f4361a237c4 to your computer and use it in GitHub Desktop.
Save jhedev/87b2e5d86f4361a237c4 to your computer and use it in GitHub Desktop.
Problem4
problem4 :: [Int] -> Int
problem4 = read . foldl1 (++) . map show . sortBy f
f:: Int -> Int -> Ordering
f x y | v1 == v2 = EQ
| v1 < v2 = GT
| v1 > v2 = LT
where
v1 = concatInt x y
v2 = concatInt y x
toString :: Int -> Int -> String
toString a b = show a ++ show b
concatInt :: Int -> Int -> Int
concatInt a = read . toString a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment