Largest int from concatenated ints: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added/changed whitespace and comments, simplified an expression.) |
(→{{header|Kotlin}}: Update Kotlin) |
||
Line 741: | Line 741: | ||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |
||
{{trans|C#}} |
{{trans|C#}} |
||
{{works with|Kotlin| |
{{works with|Kotlin|1.0b4}} |
||
<lang kotlin>import java.util.Comparator |
<lang kotlin>import java.util.Comparator |
||
Line 747: | Line 747: | ||
val xy = (x.toString() + y).toInt() |
val xy = (x.toString() + y).toInt() |
||
val yx = (y.toString() + x).toInt() |
val yx = (y.toString() + x).toInt() |
||
xy.compareTo(yx) |
|||
} |
} |
||
fun maxCat() { |
fun maxCat() { |
||
fun findLargestSequence(array: |
fun findLargestSequence(array: IntArray): String { |
||
return array. |
return array.sortedWith(SORTER).reversed().map { it.toString() }.joinToString("") |
||
} |
|||
} // Not using specialized IntArray as it does not have sortBy |
|||
⚫ | |||
⚫ | |||
println(findLargestSequence(source1)) |
println(findLargestSequence(source1)) |
||
val source2 = |
val source2 = intArrayOf(54, 546, 548, 60); |
||
println(findLargestSequence(source2)) |
println(findLargestSequence(source2)) |
||
}</lang> |
}</lang> |