A007061 The Ehrenfeucht-Mycielski sequence (1,2-version): a maximally unpredictable sequence.
1, 2, 1, 1, 2, 2, 1, 2, 1, 2, 2, 2, 1, 1, 1, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 2, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2, 1, 2, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 2
Offset: 1
Keywords
References
- N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
Links
- Joshua Zucker, Table of n, a(n) for n = 1..1999
- A. Ehrenfeucht and J. Mycielski, A pseudorandom sequence - how random is it?, Amer. Math. Monthly, 99 (1992), 373-375.
- J. C. Kieffer and W. Szpankowski, On the Ehrenfeucht-Mycielski balance conjecture, Discrete Mathematics and Theoretical Computer Science, Proceedings, 2007 Conference on Analysis of Algorithms, AofA 07, (pp. 19-30).
- Terry McConnell, The Ehrenfeucht-Mycielski Sequence
- K. Sutner, The Ehrenfeucht-Mycielski sequence, 2001
- K. Sutner, The Ehrenfeucht-Mycielski sequence, 2001 [Cached copy]
- Wikipedia, Ehrenfeucht-Mycielski sequence
Crossrefs
Programs
-
Haskell
a007061 n = a007061_list !! (n-1) a007061_list = 1 : f [1] 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 = 3 - head ys | otherwise = b xyss vs = fromJust $ find (`isInfixOf` init us) $ tails us -- Reinhard Zumkeller, Dec 05 2011
-
Python
from itertools import count, islice def agen(): astr, preval = "121", 2 yield from [1, 2, 1] while True: an = 3 - 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 from 0 to 1, Aug 18 2006
Comments