Largest int from concatenated ints: Difference between revisions
Content added Content deleted
(Updated to work with version 1.4 of Nim.) |
|||
Line 1,293: | Line 1,293: | ||
=={{header|Nim}}== |
=={{header|Nim}}== |
||
<lang nim>import algorithm, sequtils, strutils, |
<lang nim>import algorithm, sequtils, strutils, sugar |
||
proc maxNum(x: seq[int]): string = |
proc maxNum(x: seq[int]): string = |
||
var c = x.mapIt( |
var c = x.mapIt($it) |
||
c.sort((x, y) => cmp(y&x, x&y)) |
c.sort((x, y) => cmp(y&x, x&y)) |
||
c.join() |
c.join() |
||
Line 1,302: | Line 1,302: | ||
echo maxNum(@[1, 34, 3, 98, 9, 76, 45, 4]) |
echo maxNum(@[1, 34, 3, 98, 9, 76, 45, 4]) |
||
echo maxNum(@[54, 546, 548, 60])</lang> |
echo maxNum(@[54, 546, 548, 60])</lang> |
||
{{out}} |
{{out}} |
||
<pre>998764543431 |
<pre>998764543431 |