login
A090702
a(n) is the minimal number k such that every binary word of length n can be transformed into a palindrome or an antipalindrome by deleting at most k letters.
2
0, 0, 1, 1, 1, 2, 2, 2, 3, 4, 4, 4, 5, 5, 5, 6, 7, 7, 7, 8, 8, 8, 9, 10, 10, 10, 11, 11, 11, 12, 13, 13, 13, 14, 14
OFFSET
1,6
COMMENTS
A word l_0...l_n is called a palindrome if l_i = l_{n-i} for all i <= n.
A binary word l_0...l_n is called an antipalindrome if l_i <> l_{n-i} for all i <= n.
LINKS
Sean A. Irvine, Java program (github).
I. Protasov, Palindromial equivalence: one theorem and two problems, Matem. Studii, 14, #1, (2000), p. 111.
O. V. Ravsky, A New Measure of Asymmetry of Binary Words, Journal of Automata, Languages and Combinatorics, 8, #1 (2003), p. 75-83.
FORMULA
a(n) >= floor((n+2*floor((n-3)/7))/3) for every n and for 2 <= n <= 35 equality holds.
PROG
(Python)
from itertools import product
from functools import lru_cache
def ispal(w): return all(w[i] == w[-1-i] for i in range(len(w)//2+1))
def isantipal(w): return all(w[i] != w[-1-i] for i in range(len(w)//2+1))
@lru_cache(maxsize=None)
def d(w): # min deletions needed to transform w into a pal or antipal
if ispal(w) or isantipal(w): return 0
ch = set(w[:i] + w[i+1:] for i in range(len(w)))
return 1 + min(d(wc) for wc in ch)
def a(n): return max(d("0"+"".join(w)) for w in product("01", repeat=n-1))
print([a(n) for n in range(1, 18)]) # Michael S. Branicky, Jul 25 2022
CROSSREFS
Cf. A090701.
Sequence in context: A369057 A342248 A357604 * A029124 A113512 A338624
KEYWORD
nonn,base,more
AUTHOR
Sasha Ravsky (oravsky(AT)mail.ru), Jan 12 2004
EXTENSIONS
a(21)-a(35) from Sean A. Irvine, Jul 15 2022
STATUS
approved