|
|
A347582
|
|
Number of length-2n binary strings of the form xxyy.
|
|
1
|
|
|
2, 6, 20, 54, 146, 346, 848, 1922, 4424, 9810, 21816, 47598, 103730, 223498, 480542, 1025956, 2184362, 4629670, 9786512, 20618936, 43340862, 90870526, 190141128, 397049128, 827675318
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,1
|
|
LINKS
|
|
|
FORMULA
|
|
|
EXAMPLE
|
a(2) = 6: {0000, 0011, 0101, 1010, 1100, 1111}.
|
|
PROG
|
(Python)
from itertools import product
from functools import cache
@cache
def b(n): # length-2n binary strings of the form ww
return set(w+w for w in product(b"01", repeat=n))
def a(n):
return len(set(s+t for i in range(n) for s in b(i) for t in b(n-i)))
(Python) # bit-based version
from itertools import product
def b(n): # length-2n binary strings of the form ww
if n == 0: yield 0
for i in range(2**n):
yield (i << n) + i
def a(n):
st = set()
for i in range(n):
for w in b(i):
s = w << (2*(n-i))
for t in b(n-i):
st.add(s+t)
return len(st)
|
|
CROSSREFS
|
Cf. A347583, which requires x and y to be nonempty.
|
|
KEYWORD
|
nonn,more
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|