6 kyu
Van Eck's Sequence
256 of 287goldenratio161
Description:
0, 0, 1, 0, 2, 0, 2, 2, 1, 6, 0, 5, 0, 2, 6, 5, 4, 0, 5, 3, 0, 3, …
This is the Van Eck's Sequence
.
Let's go through it step by step.
Term 1: The first term is 0.
Term 2: Since we haven’t seen 0 before, the second term is 0.
Term 3: Since we have seen a 0 before, one step back, the third term is 1
Term 4: Since we haven’t seen a 1 before, the fourth term is 0
Term 5: Since we have seen a 0 before, two steps back, the fifth term is 2.
And so on...
In case you missed it, the rule here is that term n+1
is the "distance" (n - m
) between term n
, and the highest term m
with the same value, where m < n
. If there is no such m
(ie. We haven't "seen" it before) then the term is 0
. For example:
-------
V | We "saw" a 0 two positions earlier, so the next term is 2
0, 0, 1, 0, 2, 0, ?
Your task is to find the n_th number
in Van Eck's Sequence. (1-based)
There are 200 random tests of range 100 to 1000.
Good luck!
Algorithms
Similar Kata:
Stats:
Created | Jul 30, 2022 |
Published | Jul 30, 2022 |
Warriors Trained | 845 |
Total Skips | 104 |
Total Code Submissions | 900 |
Total Times Completed | 287 |
Python Completions | 256 |
C Completions | 37 |
Total Stars | 31 |
% of votes with a positive feedback rating | 90% of 72 |
Total "Very Satisfied" Votes | 60 |
Total "Somewhat Satisfied" Votes | 9 |
Total "Not Satisfied" Votes | 3 |
Total Rank Assessments | 25 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |