5 kyu
Find the smallest
1,589 of 5,748g964
Description:
You have a positive number n
consisting of digits.
You can do at most one operation:
Choosing the index of a digit in the number, remove this digit at that index and insert it back to another or at the same place in the number in order to find the smallest number you can get.
Task:
Return an array or a tuple or a string depending on the language (see "Sample Tests") with
- the smallest number you got
- the index
i
of the digitd
you took,i
as small as possible
- the index
- the index
j
(as small as possible) where you insert this digitd
to have the smallest number.
- the index
Examples:
smallest(261235) --> [126235, 2, 0] or (126235, 2, 0) or "126235, 2, 0"
126235
is the smallest number gotten by taking 1
at index 2
and putting it at index 0
smallest(209917) --> [29917, 0, 1] or ...
[29917, 1, 0] could be a solution too but index `i` in [29917, 1, 0] is greater than
index `i` in [29917, 0, 1].
29917
is the smallest number gotten by taking 2
at index 0
and putting it at index 1
which gave 029917
which is the number 29917
.
smallest(1000000) --> [1, 0, 6] or ...
Note
Have a look at "Sample Tests" to see the input and output in each language
Fundamentals
Similar Kata:
Stats:
Created | May 16, 2016 |
Published | May 16, 2016 |
Warriors Trained | 49788 |
Total Skips | 13297 |
Total Code Submissions | 131252 |
Total Times Completed | 5748 |
Ruby Completions | 210 |
Python Completions | 1589 |
JavaScript Completions | 1154 |
CoffeeScript Completions | 6 |
Java Completions | 695 |
C# Completions | 424 |
Haskell Completions | 84 |
Clojure Completions | 35 |
Elixir Completions | 61 |
C++ Completions | 473 |
TypeScript Completions | 200 |
PHP Completions | 200 |
Crystal Completions | 9 |
F# Completions | 30 |
C Completions | 265 |
Swift Completions | 100 |
R Completions | 27 |
Shell Completions | 22 |
OCaml Completions | 14 |
Groovy Completions | 12 |
Scala Completions | 65 |
Julia Completions | 19 |
Go Completions | 103 |
Nim Completions | 11 |
Racket Completions | 7 |
Reason Completions | 3 |
VB Completions | 10 |
Kotlin Completions | 78 |
Rust Completions | 89 |
Pascal Completions | 7 |
Perl Completions | 7 |
Elm Completions | 6 |
D Completions | 4 |
COBOL Completions | 4 |
Erlang Completions | 5 |
Prolog Completions | 7 |
Total Stars | 1317 |
% of votes with a positive feedback rating | 84% of 896 |
Total "Very Satisfied" Votes | 664 |
Total "Somewhat Satisfied" Votes | 169 |
Total "Not Satisfied" Votes | 63 |
Total Rank Assessments | 9 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 7 kyu |