Largest int from concatenated ints: Difference between revisions
Content added Content deleted
m (→Haskell Try all permutations method: (<$> -> fmap; needs fewer brackets)) |
|||
Line 978: | Line 978: | ||
<lang Haskell>import Data.List (permutations) |
<lang Haskell>import Data.List (permutations) |
||
main :: IO () |
|||
main = |
main = |
||
print |
print |
||
(maxcat <$> [[1, 34, 3, 98, 9, 76, 45, 4], [54, 546, 548, 60]] :: [Integer]) |
(maxcat <$> [[1, 34, 3, 98, 9, 76, 45, 4], [54, 546, 548, 60]] :: [Integer]) |
||
where |
where |
||
maxcat = read . maximum . (concatMap show |
maxcat = read . maximum . fmap (concatMap show) . permutations</lang> |
||
;Output as above. |
;Output as above. |