Anonymous user
Largest int from concatenated ints: Difference between revisions
<lang julia></lang>
(<lang julia></lang>) |
|||
Line 1,148:
=={{header|Julia}}==
Perhaps algorithm 3 is more efficient, but algorithm 2 is decent and very easy to implement in Julia. So this solution uses algorithm 2.
<lang julia>function maxconcat
b = sort(dec.(arr); lt=(x, y) -> x * y < y * x, rev=true) |> join
end
tests =
[54, 546, 548, 60],
[1, 34, 3, 98, 9, 76, 45, 4, 54, 546, 548, 60]
for
println("
end</lang>▼
▲</lang>
{{out}}
<pre>Max concatenating in [1, 34, 3, 98, 9, 76, 45, 4]:
Max concatenating in [54, 546, 548, 60]:
▲ 998764543431
▲ 6054854654
▲Maxconcating [1,34,3,98,9,76,45,4,54,546,548,60]
▲ 9987660548546544543431
=={{header|Kotlin}}==
|