Given an index integer
n, either output the
n'th item in this sequence, or output the sequence up to and including index
How does this sequence work?
NOTE: In this explanation, index
n is 1-indexed.
Put the numbers
x on two lines of length
n*6 - 1, where
x depends on the current iteration and the length of the numbers used, and then sum the digits of the
n'th/right-most Olympic Rings of those two lines.
The first number in the sequence is calculated as follows:
The length of the lines are 5 (because 1*6 - 1 = 5): 12345 67891(0) Then leave the digits in an Olympic Rings pattern: 1 3 5 7 9 And sum them: 1+3+5+7+9 = 25
n=1 results in
The second number in the sequence is calculated as follows:
The length of the lines are 11 (because 2*6 - 1 = 11): 12345678910 11121314151(6) Then leave the digits in the second/right-most Olympic Rings pattern: 7 9 0 4 5 And sum them: 7+9+0+4+5 = 25
n=2 results in
The third number in the sequence is calculated as follows:
The length of the lines are 17 (because 3*6 - 1 = 17): 12345678910111213 14151617181920212(2) Then leave the digits in the third/right-most Olympic Rings pattern: 1 2 3 0 1 And sum them: 1+2+3+0+1 = 7
n=3 results in
- When you output the
n'th item in the sequence, you are allowed to take the input as 0-indexed instead of 1-indexed, but keep in mind that the calculations of
n*6 - 1will then become
(n+1)*6 - 1or
(n+1)*5 + n.
- Single numbers of more than one digit can be split up at the end of the first line when we've reached the length
n*5 + n-1, so it is possible that a number with 2 or more digits is partially the trailing part of line 1, and partially the leading part of line 2.
- This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
- Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
- Default Loopholes are forbidden.
- If possible, please add a link with a test for your code.
- Also, please add an explanation if necessary.
Here is a paste-bin of the test cases 1-1,000, so feel free to choose any of them.
Some additional higher test cases:
1010: 24 1011: 24 2500: 19 5000: 23 7500: 8 10000: 8 100000: 25