%I #20 Sep 25 2022 21:35:31
%S 0,2,0,4,1,1,0,6,4,2,1,2,0,8,6,5,2,3,2,2,0,10,7,9,4,5,4,3,2,1,1,1,0,
%T 12,11,11,6,7,5,5,4,2,2,2,3,1,0,14,13,15,8,9,8,6,5,5,4,3,4,2,2,1,1,0,
%U 16,16,18,10,12,11,8,6,7,5,5,6,4,3,2,2,3,0
%N Variant of Inventory Sequence A342585 where indices are also counted (short version).
%C See A355916 for further information.
%H Rémy Sigrist, <a href="/A355917/b355917.txt">Table of n, a(n) for n = 1..10030</a>
%H Rémy Sigrist, <a href="/A355917/a355917.gp.txt">PARI program</a>
%e The first eight inventories are:
%e 0,
%e 2, 0,
%e 4, 1, 1, 0,
%e 6, 4, 2, 1, 2, 0,
%e 8, 6, 5, 2, 3, 2, 2, 0,
%e 10, 7, 9, 4, 5, 4, 3, 2, 1, 1, 1, 0,
%e 12, 11, 11, 6, 7, 5, 5, 4, 2, 2, 2, 3, 1, 0,
%e 14, 13, 15, 8, 9, 8, 6, 5, 5, 4, 3, 4, 2, 2, 1, 1, 0,
%e ...
%t nn = 9; c[_] = 0; i = 1; Do[k = 0; While[c[k] > 0, Set[{a[i], a[i + 1]}, {c[k], k}]; c[a[i]]++; c[a[i + 1]]++; i += 2; k++]; Set[{a[i], a[i + 1]}, {c[k], k}]; c[a[i]]++; c[a[i + 1]]++; i += 2, nn]; Array[a[2 # - 1] &, (i - 1)/2] (* _Michael De Vlieger_, Sep 25 2022 *)
%o (PARI) See Links section.
%o (Python)
%o from collections import Counter
%o def aupton(terms):
%o num, alst, inventory = 0, [0, 0], Counter([0, 0])
%o for n in range(3, 2*terms):
%o c = [inventory[num], num]
%o num = 0 if c[0] == 0 else num + 1
%o alst.extend(c)
%o inventory.update(c)
%o return alst[:2*terms:2]
%o print(aupton(82)) # _Michael S. Branicky_, Sep 25 2022
%Y Cf. A342585, A355916, A355918.
%K nonn
%O 1,2
%A _N. J. A. Sloane_, Sep 24 2022
%E More terms from _Rémy Sigrist_, Sep 25 2022