[seqfan] Re: Bag of digits

jnthn stdhr jstdhr at gmail.com
Sat Dec 14 18:49:40 CET 2019


Eric Angelini:  Thank you, and you're welcome.
David Seal: The order is left-to-right.
M. F. Hasler:  My code processes k digit-by-digit, from left to right,
removing digits from the bag as we go,  so with one four in the bag 414
becomes 14.  Python has three relevant string functions: index(), find(),
and rfind(). find and index both find the lowest index of a substring,
rfind finds the highest index ( so rfind('4', "414") returns "41" ) and
produces a slightly different sequence.

The primary sequence is https://oeis.org/draft/A330430.

On Sat, Dec 14, 2019 at 7:39 AM M. F. Hasler <seqfan at hasler.fr> wrote:

> On Sat, Dec 14, 2019 at 10:18 AM David Seal <david.j.seal at gwynmop.com>
> wrote:
>
> > There is an ambiguity in the definition of this sequence: are digits
> > considered left-to-right or right-to-left?
>
> this is first relevant for k=414. After processing k=413, I think the bag
> > is {4,5,6,7,8,9}, so a 4 is thrown away and the remaining digits of k
> are a
> > 1 and a 4 - but is the resulting sequence term 14 (as a result of the
> > digits being considered in left-to-right order) or 41 (for right-to-left
> > order)?
>
>
> I agree with the problem although I perceive it differently,
> If I understand correctly, the contents of the bag don't change until all
> digits of k are scanned.
> Only afterwards the bag is changed.
> (Else for example the first 1 of 11 would be retained but added to the bag
> and then the second one wouldn't be retained,
> but the given example says that it should, both 1's are retained, a(n)=11.)
> However, we now have that ambiguity: if we have one digit 4 in the bag and
> two digits 4 in the number.
> The rule says, the digit 4 in the bag and the digit 4 of the number cancel,
> toss them away.
> But the bag has only one digit 4 -- does it also "cancel" the second 4 in
> the number ?
> IMHO it should, in the same way the absence of 1 has allowed two digits '1'
> to "come in" earlier, and not only one.
> If not, then we have an asymmetry and the ambiguity David mentioned
> (although I would say that left-to-right would be natural,
> since it's the way we construct the sequence and we write the numbers).
>
>
> > - Maximilian
>
> > On 10 December 2019 at 21:18 jnthn stdhr <jstdhr at gmail.com> wrote:
> > > 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.
> >
>
> --
> Seqfan Mailing list - http://list.seqfan.eu/
>



More information about the SeqFan mailing list