Anonymous user
Largest int from concatenated ints: Difference between revisions
Updated D entry
(Added Mathematica) |
(Updated D entry) |
||
Line 251:
<lang d>import std.stdio, std.algorithm, std.conv, std.array, permutations2;
auto maxCat1(in int[] arr) pure {
return arr.to!(string[]).permutations.map!join.reduce!max;
}
auto maxCat2(in int[] arr) pure nothrow {
return arr.to!(string[]).sort!q{b ~ a < a ~ b}.join;
}
auto maxCat3(in int[] arr) {
immutable
return arr.to!(string[])
.schwartzSort!(s => s.replicate(
.join;
}
Line 272:
{{out}}
<pre>[["998764543431", "6054854654"], ["998764543431", "6054854654"], ["998764543431", "6054854654"]]</pre>
=={{header|Erlang}}==
|