Setup
Implement a function that rearranges an integer into its largest possible value. If the integer is already in its maximum possible value, simply return it.
Examples
superSize(123456)
//654321
superSize(105)
//510
Tests
superSize(513)
superSize(2020)
superSize(4194)
superSize(608719)
superSize(123456789)
superSize(700000000001)
superSize(666666)
Good luck!
This challenge comes from ozymandias1 on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email yo+challenge@dev.to with your suggestions!
Top comments (14)
JavaScript oneliners for the win!
Had a feeling it was this simple.
Why the plus though?
The argument to the unary plus operator is a string. The + is a very concise method of converting a string to a number, in this situation.
Ah, I totes prefer the readability over conciseness approach
dart
I'm sure this could be done shorter.
Javascript
In JS, implementing Bubble Sort just because.
in C++ using the standard template library:
Javascript solution for superSize :)
Yet another Ruby one liner:
Also neat how it reads almost literarly, no need to explain each step in the chain!
Scala