I've been really interested with sequences that follow the property
\$a(n+1) = a(n - a(n))\$
recently, so here's another question about these sequences. In particular we are concerned with sequences from the integers to the natural numbers.
A periodic sequence with the above property is an n-Juggler if and only if it contains exactly n distinct values. For example the following sequence is a 2 juggler
... 2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1 ...
because it only contains the numbers 1
and 2
.
An example of a three juggler would be
... 3,5,3,5,1,5,3,5,3,5,1,5,3,5,3,5,1,5,3,5,3,5,1,5,3,5,3,5,1,5,3,5,3,5,1,5 ...
because it juggles 1
, 3
, and 5
.
Task
Given n > 1 as input, output any n-Juggler.
You may output a sequence in a number of ways, you can
output a function that indexes it.
take an additional input of the index and output the value at that index.
output a continuous subsection of the sequence that, with the given property uniquely determines the sequence.
This is code-golf so answers are scored in bytes with less bytes being better.
a(n+1) = a(n-a(n))
, and not + \$\endgroup\$2,2
once →2,2,2,2
, repeat again →2,2,2,2,2,2
, etc. There's absolutely no way to get a1
from repeating2,2
. The sequence you get is always unique. \$\endgroup\$