[seqfan] Re: Bag of digits

M. F. Hasler oeis at hasler.fr
Sun Dec 15 17:57:19 CET 2019


On Sun, Dec 15, 2019, 02:28 jnthn stdhr <jstdhr at gmail.com> wrote:

> 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.


Yes, the "removing" is done immediately, but the "adding" only later.
That is the asymmetry I mentioned:

If we have *no* digit d in the bag, then all digits d in k are retained and
added to the bag *only after* all digits of k are processed.
But if we do have digit(s) d in the bag, then they are consumed
*immediately* as they cancel out with the first digits(s) d in k, and once
they are consumed, further d's in k will be retained and subsequently
(again *not immediately*) be added to the bag.

-M.

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.
>



More information about the SeqFan mailing list