The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A307226 Triangle read by rows: drop and bounce. 1
 0, 0, 1, 0, 1, 2, 0, 1, 3, 2, 0, 4, 1, 3, 2, 0, 4, 5, 1, 3, 2, 0, 4, 6, 5, 1, 3, 2, 7, 0, 4, 6, 5, 1, 3, 2, 7, 0, 4, 6, 5, 1, 3, 2, 8, 7, 0, 4, 6, 5, 1, 3, 2, 9, 8, 7, 0, 4, 6, 5, 1, 3, 10, 2, 9, 8, 7, 0, 4, 6, 5, 1, 11, 3, 10, 2, 9, 8 (list; table; graph; refs; listen; history; text; internal format)
 OFFSET 0,6 COMMENTS Number k starts with 1, 2, 3, ... 'points' and is 'dropped' on the initial value of 0. k then 'bounces' on the numbers already in the sequence according to the following rules: - k loses 1 point for each bounce. - After the first bounce (i.e., on 0) k moves to the right. If k bounces on a number already in the sequence which has a higher value than k, then the direction reverses. At lower or equal values, k continues to move in the same direction. - If k reaches the start or the end of the sequence or has 0 points left, the starting value of k is added to the sequence at that position. LINKS EXAMPLE For k = 4: 4 points, bounce on 0, move to the right; 3 points, bounce on 1, move to the right; 2 points, bounce on 3, reverse direction; 1 point, bounce on 1, move to the left; 0 points: k = 4 is inserted between 0 and 1. (Although equal to the next value 0, k has no more points left to bounce over it.) The first iterations:   [0];   [0, 1];   [0, 1, 2];   [0, 1, 3, 2];   [0, 4, 1, 3, 2];   [0, 4, 5, 1, 3, 2];   [0, 4, 6, 5, 1, 3, 2];   [7, 0, 4, 6, 5, 1, 3, 2];   [7, 0, 4, 6, 5, 1, 3, 2, 8];   ... PROG (Python) seq = [0] for k in range (1, 10):   points = k   position = seq.index(0)   direction = 1   while points > 0 and position >= 0 and position < len(seq):     if points < seq[position]: direction *= -1     points -= 1     position += direction   else:     if position < 0: seq.insert(0, k)     elif position == len(seq): seq.append(k)     elif points == 0 and direction == 1: seq.insert(position, k)     else: seq.insert(position - direction, k) print(seq) (PARI) process(row, n) = {my(pos = 1, dir = 1, m = n); while (m && (pos >= 1) && (pos <= #row), if (m < row[pos], dir = -dir); pos += dir; m--; ); if (pos == 0, return (concat(n, row))); if (pos == #row +1, return (concat(row, n))); if (dir == -1, pos ++); my(nrow = vector(#row+1)); for (k=1, pos-1, nrow[k] = row[k]; ); nrow[pos] = n; for (k = pos+1, #row+1, nrow[k] = row[k-1]; ); return (nrow); } tabl(nn) = {row = [0]; print(row); for (n=1, nn, row = process(row, n); print(row); ); } \\ Michel Marcus, Apr 13 2019 CROSSREFS Cf. A307326. Sequence in context: A319284 A338526 A182703 * A263390 A231354 A197119 Adjacent sequences:  A307223 A307224 A307225 * A307227 A307228 A307229 KEYWORD nonn,tabl AUTHOR Jan Koornstra, Mar 31 2019 STATUS approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

Last modified May 10 05:05 EDT 2021. Contains 343748 sequences. (Running on oeis4.)