Anonymous user
Largest int from concatenated ints: Difference between revisions
Added Mathematica
m (→{{header|C}}: Remove cmopletely frivolous const modifiers.) |
(Added Mathematica) |
||
Line 542:
<pre>998764543431
6054854654</pre>
=={{header|Mathematica}}==
<lang Mathematica>makeLargestInt[list_] := Module[{sortedlist},
sortedlist = Sort[list, Order[ToString[#1] <> ToString[#2], ToString[#2] <> ToString[#1]] < 0 &];
Map[ToString, sortedlist] // StringJoin // FromDigits
]
(* testing with two examples *)
makeLargestInt[{1, 34, 3, 98, 9, 76, 45, 4}]
makeLargestInt[{54, 546, 548, 60}]</lang>
{{Output}}
<pre>998764543431
6054854654</pre>
=={{header|NetRexx}}==
|