Largest int from concatenated ints: Difference between revisions

m
update for 1.0+
m (adding closing parenthesis missing from iterator in for loop.)
m (update for 1.0+)
Line 1,151:
 
=={{header|Julia}}==
{{works with|Julia|0.6}}
 
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(arr::Vector{<:Integer})
b = sort(decstring.(arr); lt=(x, y) -> x * y < y * x, rev=true) |> join
return try parse(Int, b) catch parse(BigInt, b) end
end
4,105

edits