%I #31 Oct 13 2021 10:26:39
%S 0,1,1,0,2,2,2,0,3,2,4,1,1,0,4,4,4,1,4,0,5,5,4,1,6,2,1,0,6,7,5,1,6,3,
%T 3,1,0,7,9,5,3,6,4,4,2,0,1,0,9,10,6,4,9,4,5,2,0,3,1,0,11,11,7,5,10,6,
%U 6,3,0,3,2,2,0
%N An alternative version of the inventory sequence A342585: now a row only ends when a 0 is reached that would not be followed by any further terms.
%C This sequence has offset 0, which seems more appropriate than the offset 1 that A342585 has.
%C In both A342585 and the present sequence, a row records the numbers of 0's, 1's, 2's, etc., in the sequence so far.
%C The difference is that in A342585 a row ends when the first 0 is reached. The row beginning 7, for example, is 7, 9, 5, 3, 6, 4, 4, 2, 0, and ends, because there is no 8 in the sequence up to this point. However, there is a 9, so we can say that the row ended prematurely.
%C In the present sequence we continue the row until we reach a 0 which is 1 more than the highest term in the sequence up to that point, and then the row ends.
%C So the row beginning 7 is now 7, 9, 5, 3, 6, 4, 4, 2, 0, 1, 0.
%C From this point on the two sequences differ.
%C Unfortunately, this version has the drawback that most of the entries are zero!
%H Michael S. Branicky, <a href="/A347317/b347317.txt">Table of n, a(n) for n = 0..25000</a>
%e The triangle begins:
%e 0;
%e 1, 1, 0;
%e 2, 2, 2, 0;
%e 3, 2, 4, 1, 1, 0;
%e 4, 4, 4, 1, 4, 0;
%e 5, 5, 4, 1, 6, 2, 1, 0;
%e 6, 7, 5, 1, 6, 3, 3, 1, 0;
%e 7, 9, 5, 3, 6, 4, 4, 2, 0, 1, 0;
%e 9, 10, 6, 4, 9, 4, 5, 2, 0, 3, 1, 0;
%e 11, 11, 7, 5, 10, 6, 6, 3, 0, 3, 2, 2, 0;
%e ...
%t Block[{c, k, m, r = 0}, c[0] = 1; {0}~Join~Reap[Do[k = 0; While[k <= r, If[IntegerQ@ c[k], Set[m, c[k]], Set[c[k], 0]; Set[m, 0]]; If[m > r, r = m]; Sow[m]; If[IntegerQ@ c[m], c[m]++, c[m] = 1]; k++]; Sow[0]; c[0]++, 9]][[-1, -1]]] (* _Michael De Vlieger_, Oct 12 2021 *)
%o (Python)
%o from collections import Counter
%o def aupton(terms):
%o num, alst, inventory = 0, [0], Counter([0])
%o for n in range(2, terms+1):
%o c = inventory[num]
%o if c == 0 and num > max(inventory):
%o num = 0
%o else:
%o num += 1
%o alst.append(c); inventory.update([c])
%o return alst
%o print(aupton(73)) # _Michael S. Branicky_, Sep 09 2021
%Y Cf. A342585. See A347318 for row lengths.
%K nonn,tabf
%O 0,5
%A _N. J. A. Sloane_, Sep 09 2021