|
|
A306470
|
|
a(0) = 0; for n > 0, if the number of blanks already in the sequence is greater than or equal to n, n is filled in at the n-th blank counting from the end of the sequence; otherwise n is added to the end of the sequence followed by n blanks.
|
|
3
|
|
|
0, 1, 3, 2, 9, 5, 4, 120, 8, 14, 7, 6, 22, 13, 34, 12, 21, 11, 10, 52, 20, 33, 19, 79, 18, 32, 17, 51, 16, 15, 31, 181, 30, 50, 29, 78, 28, 49, 27, 119, 26, 48, 25, 77, 24, 23, 47, 615, 46, 76, 45, 118, 44, 75, 43, 180, 42, 74, 41, 117, 40, 73
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,3
|
|
COMMENTS
|
The consecutive number of blanks added to the sequence (1, 2, 4, 6, 10, 15, ...) appear to form the sequence A112088 - 1. The unique values for the length of the sequence (1, 3, 6, 11, 18, 29, 45, 69, 105, ...) then becomes 1 + the partial sums of A112088.
|
|
LINKS
|
|
|
EXAMPLE
|
For n < 3, n is added to the sequence along with n blanks (denoted by -1): [0, 1, -1, 2, -1, -1]. There are now three blanks in the sequence, hence n = 3 is filled in at the third blank counting from the end of the sequence: [0, 1, 3, 2, -1, -1].
|
|
MATHEMATICA
|
TakeWhile[Nest[Function[{a, n, b}, If[b >= n, ReplacePart[a, Position[a, -1][[-n]] -> n ], Join[a, Prepend[ConstantArray[-1, n], n]]]] @@ {#, Max@ # + 1, Count[#, -1]} &, {0}, 10^3], # > -1 &] (* Michael De Vlieger, Mar 24 2019 *)
|
|
PROG
|
(Python 3)
seq = [0]
for n in range(1, 1387):
num_blanks = seq.count(-1)
if num_blanks >= n: seq[[index for index, value in enumerate(seq) if value == -1][num_blanks - n]] = n
else: seq += [n] + [-1] * n
print(seq[:100])
|
|
CROSSREFS
|
|
|
KEYWORD
|
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|