cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A330430 Consider integers k=0,1,2,... as strings. Compare each digit in the string, in left-to-right order, with the contents of a bag (multiset) of digits, which is initially empty. If digit d is in the bag delete d from both the string and the bag. What remains of any nonempty string is appended to the sequence and its digits are added to the bag.

This page as a plain text file.
%I A330430 #17 Feb 04 2020 14:56:04
%S A330430 0,1,2,3,4,5,6,7,8,9,11,1,1,1,20,1,22,3,4,25,6,27,8,29,3,33,3,3,40,1,
%T A330430 42,3,44,5,6,47,8,49,5,5,55,5,60,1,62,3,64,5,66,7,8,69,7,7,7,77,80,1,
%U A330430 82,3,84,5,86,7,88,9,9,9,9,9,99,100,1,2,103,4,105
%N A330430 Consider integers k=0,1,2,... as strings. Compare each digit in the string, in left-to-right order, with the contents of a bag (multiset) of digits, which is initially empty. If digit d is in the bag delete d from both the string and the bag. What remains of any nonempty string is appended to the sequence and its digits are added to the bag.
%H A330430 Rémy Sigrist, <a href="/A330430/b330430.txt">Table of n, a(n) for n = 1..10000</a>
%e A330430 Beginning with k=0, the bag is initially empty and 0 matches nothing in the bag, so the sequence is extended and 0 is added to the bag.  Likewise, for k=1-9, none of these digits match anything in the bag, resulting in the sequence [0,1,2,3,4,5,6,7,8,9] and a bag that contains {0,1,2,3,4,5,6,7,8,9}.
%e A330430 With k=10, Both the 1 and the 0 in k are matched with the 1 and the 0 in the bag and cancel out.  This leaves an empty string, so the sequence is not extended, and the bag now contains {2,3,4,5,6,7,8,9}.
%e A330430 With k=11, neither digit cancels out, since there are no ones in the bag, so the sequence is extended, [0,1,2,3,4,5,6,7,8,9,11], and the bag contains {1,1,2,3,4,5,6,7,8,9}.
%o A330430 (Python)
%o A330430 seq = []
%o A330430 bag = ""
%o A330430 for k in range(1000):
%o A330430   m = str(k)
%o A330430   for digit in m:
%o A330430     if digit in bag:
%o A330430       mndx = m.index(digit)
%o A330430       m = m[:mndx] + m[mndx+1:]
%o A330430       bndx = bag.index(digit)
%o A330430       bag = bag[:bndx] + bag[bndx+1:]
%o A330430   if m:
%o A330430     seq.append(int(m))
%o A330430     bag = bag + m
%o A330430 print(seq)
%o A330430 (PARI) { my (b=vector(base=10), n=0); for (k=0, 105, d = if (k, digits(k,base), [0]); t = []; for (i=1, #d, if (b[1+d[i]], b[1+d[i]]--, t=concat(t, d[i]););); if (#t, print1 (fromdigits(t,base)", "); for (j=1, #t, b[1+t[j]]++))) } \\ _Rémy Sigrist_, Dec 15 2019
%K A330430 nonn,easy,base
%O A330430 1,3
%A A330430 _J. Stauduhar_, Dec 14 2019