Rotate for a Max
Description:
Let us begin with an example:
Take a number: 56789
. Rotate left, you get 67895
.
Keep the first digit in place and rotate left the other digits: 68957
.
Keep the first two digits in place and rotate the other ones: 68579
.
Keep the first three digits and rotate left the rest:
68597
.
Now it is over since keeping the first four it remains only one digit which
rotated is itself.
You have the following sequence of numbers:
56789 -> 67895 -> 68957 -> 68579 -> 68597
and you must return the greatest: 68957
.
Task
Write function max_rot(n)
which given a positive integer n
returns the maximum number you got doing rotations similar to the above example.
So max_rot
(or maxRot
or ... depending on the language) is such as:
max_rot(56789) should return 68957
max_rot(38458215) should return 85821534
Similar Kata:
Stats:
Created | Jan 24, 2016 |
Published | Jan 24, 2016 |
Warriors Trained | 39086 |
Total Skips | 7214 |
Total Code Submissions | 89665 |
Total Times Completed | 11050 |
Ruby Completions | 329 |
Python Completions | 2893 |
JavaScript Completions | 2941 |
CoffeeScript Completions | 18 |
Haskell Completions | 140 |
Clojure Completions | 75 |
C# Completions | 593 |
Java Completions | 1760 |
Elixir Completions | 153 |
C++ Completions | 850 |
PHP Completions | 551 |
TypeScript Completions | 253 |
Crystal Completions | 9 |
F# Completions | 66 |
C Completions | 346 |
Shell Completions | 135 |
OCaml Completions | 33 |
Kotlin Completions | 380 |
Julia Completions | 18 |
R Completions | 68 |
PowerShell Completions | 55 |
Go Completions | 397 |
Nim Completions | 9 |
Racket Completions | 23 |
Reason Completions | 3 |
Scala Completions | 57 |
Perl Completions | 38 |
Prolog Completions | 7 |
Rust Completions | 111 |
Lua Completions | 56 |
Factor Completions | 10 |
Total Stars | 653 |
% of votes with a positive feedback rating | 86% of 1683 |
Total "Very Satisfied" Votes | 1303 |
Total "Somewhat Satisfied" Votes | 288 |
Total "Not Satisfied" Votes | 92 |