login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A157238
0-1 sequence generated by starting with a 0, and then by using whichever of 0, 1 will result in the shortest sequence repeated at the end.
4
0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0
OFFSET
1,1
COMMENTS
The same as the Linus sequence (A006345): a(n) "breaks the pattern" by avoiding the longest doubled suffix, but using 0's and 1's. - Robert G. Wilson v, Dec 01 2013
FORMULA
a(n) = A006345(n) - 1. - Robert G. Wilson v, Dec 02 2013
EXAMPLE
a(6)=1 as 0,1,0,0,1,1 has a longest repeated sequence of length 1 at the end, whereas 0,1,0,0,1,0 has a longest repeated sequence of length 3 at the end. Similarly, a(7)=0 since 0,1,0,0,1,1,0 has a longest repeated sequence of length 0 at the end.
PROG
(Python)
x = [0]
while len(x) < 1000:
t = x[-1]
z = 1
while 2 * z + 1 <= len(x):
if x[-z:] == x[-(2 * z + 1) : -(z + 1)]:
t = x[-(z + 1)]
z += 1
x.append(1 - t)
print(x)
CROSSREFS
Sequence in context: A368463 A080846 A082401 * A337546 A059448 A283318
KEYWORD
nonn
AUTHOR
Luke Pebody (luke.pebody(AT)gmail.com), Feb 25 2009
STATUS
approved