Largest int from concatenated ints: Difference between revisions
Content added Content deleted
(→Compare repeated string method: change ruby per python change) |
|||
Line 127: | Line 127: | ||
where sorted = sortBy (\a b -> compare (b++a) (a++b)) |
where sorted = sortBy (\a b -> compare (b++a) (a++b)) |
||
maxcat = read . concat . sorted . map show</lang> |
maxcat = read . concat . sorted . map show</lang> |
||
;Output as above. |
|||
===Try all permutations method=== |
|||
<lang Haskell>import Data.List (sort, permutations) |
|||
main = print (map maxcat [[1,34,3,98,9,76,45,4], [54,546,548,60]] :: [Integer]) |
|||
where maxcat = read . last . sort . map (concat . map show) . permutations</lang> |
|||
;Output as above. |
;Output as above. |