[seqfan] Bag of digits

jnthn stdhr jstdhr at gmail.com
Tue Dec 10 22:18:49 CET 2019


Hi folks.

Start with an empty bag of digits.  For each k =0,1,2,... compare the
digits of k with the contents of the bag.  If a digit of k matches a digit
in the bag throw them in the trash (they cancel each other out).  Add the
concatenation m of what remains of k to the sequence and toss the digits of
m into the bag.  Note that if m contains leading zeros they are stripped
away in the seq. but added to the bag.

Initially no digits are in the bag so the first ten terms are
[0,1,2,3,4,5,6,7,8,9] and the bag contains (0,1,2,3,4,5,6,7,8,9).

Now with k=10, we match both digits and nothing remains to add to the
sequence or the bag,so the sequence remains unchanged and the bag now
contains (2,3,4,5,6,7,8,9).

With k=11, we match nothing, so 11 is added to the seq. ->
[0,1,2,3,4,5,6,7,8,9,11]  and two ones are added to the bag ->
(1,1,2,3,4,5,6,7,8,9).

With k=12 and k=13, all digits are matched and the seq. is unchanged, and
the bag is left with (4,5,6,7,8,9)

With k=14, the fours cancel and the one remains, so 1 is added to the seq.
and to the bag.

Etc.

The sequence begins:
[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, 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, 82, 3, 84, 5, 86, 7, 88, 9, 9,
9, 9, 9, 99, 100, 1, 2, 103, 4, 105, 6, 107, 8, 10, 1, 11, 11, 11, 11, 11,
20, 1, 22, 13, 4, 125, 6, 127, 8, 129, 131, 33, 1, 13, 13, 140, 1, 42, 13,
44, 15, 6, 147, 8, 149, 151, 5, 1, 55, 1, 15, 160, 1, 62, 13, 64, 15, 66,
17, 8, 169, 171, 7, 1, 7, 1, 77, 1, 180, 1, 82, 13, 84, 15, 86, 17, 88, 19,
191, 9, 1, 9, 1, 9, 1, 99, 200]

The bag size always remains small.  For k > 9 record bag sizes occur at
(k:record size) 808:11, 8008:12, 10008:13, 80008:15, 800008:16,
1000008:17.  Is there a simple explanation for why these k's all end with
an eight?

The seq. of integers where no digits are canceled out is:
[0,1,2,3,4,5,6,7,8,9,11,20,22,25,27,29,33,40,42,44,47,49,55,60,...]

The seq. of integers where all digits are canceled out is:
[10, 12, 13, 15, 17, 19, 30, 32, 34, 35, 37, 39, 50, 52, 54, 56, 57, 59,
70, 72, 74, 76, 78, 79, 90, 92, 94, 96, 98, 112, 114, 116, 118, 130, 132,
135, 137, 139, 150, 152, 157, 159, 170, 172, 179, 190, 192, 210, 213, 215,
217, 219, 230, 235, 237, 239, 250, 257, 259, 270, 279, 290, 310,...]

Should I add these?

-Jonathan

Python code:

seq = []
bag = ""
#for first 10K term set range(11256)
for k in range(1000):
  m = str(k)
  for digit in m:
    if digit in bag:
      #Remove digit from m and bag.
      mndx = m.index(digit)
      m = m[:mndx] + m[mndx+1:]
      bndx = bag.index(digit)
      bag = bag[:bndx] + bag[bndx+1:]
  if m:
    seq.append(int(m))
    bag = bag + m

print(seq)



More information about the SeqFan mailing list