login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A237502 Number of binary strings of length 2n that contain the ones' complements and the reversals of each of their two halves. 3

%I #17 Feb 01 2024 14:28:27

%S 2,6,8,16,26,46,72,116,184,288,434,646,980,1444,2122,3066,4500,6452,

%T 9362,13294,19256,27280,39242,55306,79546,111990,160514,225466,323108,

%U 453520,648970,909942,1301932,1825044,2609142,3655406,5225912,7320748,10461942,14651858

%N Number of binary strings of length 2n that contain the ones' complements and the reversals of each of their two halves.

%H Michael S. Branicky, <a href="/A237502/a237502.py.txt">Python program</a>

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

%t 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]

%o (Python) # see link for faster version

%o from itertools import product as prod

%o def comp(s): z, o = ord('0'), ord('1'); return s.translate({z:o, o:z})

%o def ok(s):

%o a, b = s[len(s)//2:], s[:len(s)//2]

%o return comp(a) in s and comp(b) in s and a[::-1] in s and b[::-1] in s

%o def a(n): return 2*sum(ok("0"+"".join(p)) for p in prod("01", repeat=2*n-1))

%o print([a(n) for n in range(1, 12)]) # _Michael S. Branicky_, Feb 06 2021

%Y Cf. A237500, A237501.

%K nonn

%O 1,1

%A _Giovanni Resta_, Feb 08 2014

%E a(21)-a(40) from _Max Alekseyev_, Feb 01 2024

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 01:35 EDT 2024. Contains 371964 sequences. (Running on oeis4.)