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.

Showing 1-2 of 2 results.

A308174 Let EM denote the Ehrenfeucht-Mycielski sequence A038219, and let P(n) = [EM(1),...,EM(n)]. To compute EM(n+1) for n>=3, we find the longest suffix S (say) of P(n) which has previously appeared in P(n). Suppose the most recent appearance of S began at index n-t(n). Then a(n) = length of S, while t(n) is given in A308175.

Original entry on oeis.org

1, 1, 2, 1, 2, 2, 3, 3, 3, 2, 3, 3, 2, 3, 3, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6
Offset: 3

Views

Author

N. J. A. Sloane, May 21 2019, corrected and extended May 21 2019

Keywords

Comments

Then EM(n+1) is the complement of the bit following the most recent appearance of S.

Examples

			Tableau showing calculation of terms 3 through 13
1   2   3   4   5   6   7   8   9  10  11  12  13  n
0   1   0   0   1   1   0   1   0   1   1   1   0  A038219(n)
-   -   0   0  01   1  10  01 010 101 011  11 110  S
-   -   1   1   2   1   2   2   3   3   3   2   3  s = A308174(n)
-   -   1   3   1   5   2   4   1   6   4  10   5  previous
-   -   2   1   4   1   5   4   8   4   7   2   8  t = A308175(n)
"Previous" = index of start of most recent previous occurrence of S; s = |S|; t = n - "previous" = A308175(n)
		

Crossrefs

Programs

  • Perl
    See Links section.

Extensions

More terms from Rémy Sigrist, May 21 2019

A038219 The Ehrenfeucht-Mycielski sequence (0,1-version): a maximally unpredictable sequence.

Original entry on oeis.org

0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1
Offset: 1

Views

Author

Keywords

Comments

The sequence starts 0,1,0 and continues according to the following rule: find the longest suffix that has occurred at least once previously. If there is more than one previous occurrences select the most recent one. The next digit of the sequence is the opposite of the one following the previous occurrence. - Christopher Carl Heckman, Feb 10 2005

Examples

			We start with a(1)=0, a(2)=1, a(3)=0.
The longest suffix we have seen before is "0", when it occurred at the start, followed by 1. So a(4) = 0. We now have 0100.
The longest suffix we have seen before is again "0", when it occurred at a(3), followed by a(4)=0. So a(5) = 1. We now have 01001.
The longest suffix we have seen before is "01", when it occurred at a(1),a(2), followed by a(3)=0. So a(6) = 1. We now have 010011.
And so on.
For further illustrations of calculating these terms, see A308174 and A308175. - _N. J. A. Sloane_, May 21 2019
		

Crossrefs

Cf. A007061 (1, 2 version).
Cf. A201881 (run lengths).
Cf. also A253059, A253060, A253061.
For first appearance of subwords see A308173.
A308174, A308175 are used in the calculation of a(n).

Programs

  • Haskell
    a038219 n = a038219_list !! n
    a038219_list = 0 : f [0] where
       f us = a' : f (us ++ [a']) where
            a' = b $ reverse $ map (`splitAt` us) [0..length us - 1] where
               b ((xs,ys):xyss) | vs `isSuffixOf` xs = 1 - head ys
                                | otherwise          = b xyss
            vs = fromJust $ find (`isInfixOf` init us) $ tails us
    -- Reinhard Zumkeller, Dec 05 2011
    
  • Maple
    See Lunnon link.
  • Perl
    See Links section.
    
  • Python
    from itertools import count, islice
    def agen():
        astr, preval = "010", 1
        yield from [0, 1, 0]
        while True:
            an = 1 - preval
            yield an
            astr += str(an)
            for l in range(len(astr)-1, 0, -1):
                idx = astr.rfind(astr[-l:], 0, len(astr)-1)
                if idx >= 0: preval = int(astr[idx+l]); break
    print(list(islice(agen(), 105))) # Michael S. Branicky, Aug 03 2022

Extensions

More terms from Joshua Zucker, Aug 11 2006
Offset changed by Reinhard Zumkeller, Dec 11 2011
Edited by N. J. A. Sloane, May 12 2019
Showing 1-2 of 2 results.