OFFSET
1,1
LINKS
Max Alekseyev, Table of n, a(n) for n = 1..71
Michael S. Branicky, Python program
EXAMPLE
The two halves of 1000111000 are 10001 and 11000. Their reversals are 10001 and 00011, and their complements are 01110 and 00111 and all are substrings of 1000111000. Since there are 25 other strings of length 2*5 with this property, a(5) = 26.
MATHEMATICA
sQ[L_, {s__}] := MatchQ[L, {___, s, ___}]; a[n_] := Length@ Select[ Tuples[{0, 1}, 2*n], sQ[#, Reverse[Take[#, n]]] && sQ[#, Reverse[Take[#, -n ]]] && sQ[#, 1 - Take[#, n]] && sQ[#, 1 - Take[#, -n]] &]; Array[a, 8]
PROG
(Python) # see link for faster version
from itertools import product as prod
def comp(s): z, o = ord('0'), ord('1'); return s.translate({z:o, o:z})
def ok(s):
a, b = s[len(s)//2:], s[:len(s)//2]
return comp(a) in s and comp(b) in s and a[::-1] in s and b[::-1] in s
def a(n): return 2*sum(ok("0"+"".join(p)) for p in prod("01", repeat=2*n-1))
print([a(n) for n in range(1, 12)]) # Michael S. Branicky, Feb 06 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Giovanni Resta, Feb 08 2014
EXTENSIONS
a(21)-a(40) from Max Alekseyev, Feb 01 2024
STATUS
approved