Given an positive integer n
(including 0 if you decide to support it), output all numbers in the generated sequence up to the index n
. For the current test cases of the current challenge numbers are one-indexed. Feel free to submit 0-indexed answers though.
Base sequence
We start from this sequence (NOT, but quite similar to, A160242):
1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, ...
This sequence should be more understandable after formatting:
1, 2, 1,
1, 2, 2, 2, 1,
1, 2, 2, 2, 2, 2, 1,
and so on ...
However, our point is not to output this sequence. See the below procedure.
Adding the sequence
Here's an example of adding the sequence. Here, our sequence starts with 0:
We collect all intermediate results into the sequence.
The sequence
| Output sequence: [0]
v
0 + 1 = 1 Output sequence: [0, 1]
1 + 2 = 3 Output sequence: [0, 1, 3]
3 + 1 = 4 Output sequence: [0, 1, 3, 4]
4 + 1 = 5 Output sequence: [0, 1, 3, 4, 5]
...
Our generated sequence is therefore
0, 1, 3, 4, ...
Test cases
Here is a sample program outputting the sequence up to the input.
3 -> [0, 1, 3]
10 -> [0, 1, 3, 4, 5, 7, 9, 11, 12, 13]
[1, 3, 4, 5, 7, 9, 11, 12, 13, 15]
for10
? \$\endgroup\$1, 2 (xN), 1
repeated arbitrary times" is confusing and doesn't tell me how to generate the base sequence. Then you have the sentence where you explain how to go from the base seq. to the generated sequence. Which also is not clear at all... Then you also have this rule about my sequence not being allowed to start at 1..? \$\endgroup\$