Unique digits sequence
Description:
Consider the following series:
0,1,2,3,4,5,6,7,8,9,10,22,11,20,13,24...
There is nothing special between numbers 0
and 10
.
Let's start with the number 10
and derive the sequence. 10
has digits 1
and 0
. The next possible number that does not have a 1
or a 0
is 22
. All other numbers between 10
and 22
have a 1
or a 0
.
From 22
, the next number that does not have a 2
is 11
. Note that 30
is also a possibility because it is the next higher number that does not have a 2
, but we must select the lowest number that fits and is not already in the sequence.
From 11
, the next lowest number that does not have a 1
is 20
.
From 20
, the next lowest number that does not have a 2
or a 0
is 13
, then 24
, then 15
and so on.
Once a number appers in the series, it cannot appear again.
You will be given an index number and your task will be return the element at that position. See test cases for more examples.
Note that the test range is n <= 500
.
Good luck!
If you like this Kata, please try:
https://www.codewars.com/kata/unique-digit-sequence-ii-optimization-problem
Similar Kata:
Stats:
Created | Aug 18, 2017 |
Published | Aug 18, 2017 |
Warriors Trained | 2736 |
Total Skips | 220 |
Total Code Submissions | 3342 |
Total Times Completed | 835 |
Haskell Completions | 32 |
Python Completions | 486 |
JavaScript Completions | 164 |
Ruby Completions | 43 |
C++ Completions | 51 |
C# Completions | 36 |
Java Completions | 58 |
Total Stars | 106 |
% of votes with a positive feedback rating | 95% of 184 |
Total "Very Satisfied" Votes | 165 |
Total "Somewhat Satisfied" Votes | 18 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 10 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 6 kyu |