Python 3.8, (削除) 273 (削除ここまで) \$\cdots\$(削除) 316 (削除ここまで) 312 bytes
Added 30 bytes to fix bugs kindly pointed out by Bubbler.
Added 12 bytes to fix a bug kindly pointed out by ovs.
Saved 9 bytes thanks to ovs!!!
def f(*x,i=0):
b,a=w=sorted(x,key=len);d,c=map(len,w)
while a[i]==b[i]:
if(i:=i+1)==d:return i==c-42
while a[c-1]==b[d-1]:
if d==1:return c==3
c-=1;d-=1
a=a[i:c]
b=b[i:d]
return c-i>1and((x:=a[1:-1])==(y:=b[1:-1])or a[:-1]==y or a[1:]==y or a[:-1]==b[1:]or a[1:]==b[:-1]or x==b[:-1]or x==b[1:]or x==b)
Python 3.8, (削除) 273 (削除ここまで) \$\cdots\$(削除) 316 (削除ここまで) 312 bytes
Added 30 bytes to fix bugs kindly pointed out by Bubbler.
Added 12 bytes to fix a bug kindly pointed out by ovs.
Saved 9 bytes thanks to ovs!!!
def f(*x,i=0):
b,a=w=sorted(x,key=len);d,c=map(len,w)
while a[i]==b[i]:
if(i:=i+1)==d:return i==c-4
while a[c-1]==b[d-1]:
if d==1:return c==3
c-=1;d-=1
a=a[i:c]
b=b[i:d]
return c-i>1and((x:=a[1:-1])==(y:=b[1:-1])or a[:-1]==y or a[1:]==y or a[:-1]==b[1:]or a[1:]==b[:-1]or x==b[:-1]or x==b[1:]or x==b)
Python 3.8, (削除) 273 (削除ここまで) \$\cdots\$(削除) 316 (削除ここまで) 312 bytes
Added 30 bytes to fix bugs kindly pointed out by Bubbler.
Added 12 bytes to fix a bug kindly pointed out by ovs.
Saved 9 bytes thanks to ovs!!!
def f(*x,i=0):
b,a=w=sorted(x,key=len);d,c=map(len,w)
while a[i]==b[i]:
if(i:=i+1)==d:return i==c-2
while a[c-1]==b[d-1]:
if d==1:return c==3
c-=1;d-=1
a=a[i:c]
b=b[i:d]
return c-i>1and((x:=a[1:-1])==(y:=b[1:-1])or a[:-1]==y or a[1:]==y or a[:-1]==b[1:]or a[1:]==b[:-1]or x==b[:-1]or x==b[1:]or x==b)
Python 3.8, (削除) 273 (削除ここまで) \$\cdots\$(削除) 321316 (削除ここまで) 316312 bytes
Added 30 bytes to fix bugs kindly pointed out by Bubbler.
Added 12 bytes to fix a bug kindly pointed out by ovs.
Saved 59 bytes thanks to ovs!!!
def f(*x,i=0):
b,a=w=sorted(x,key=len);d,c=map(len,w)
while a[i]==b[i]:
if i==d-1(i:=i+1)==d:return i==c-3
i+=14
while a[c-1]==b[d-1]:
if d==1:return c==3
c-=1;d-=1
a=a[i:c]
b=b[i:d]
return c-i>1 andi>1and((x:=a[1:-1])==(y:=b[1:-1])or a[:-1]==y or a[1:]==y or a[:-1]==b[1:]or a[1:]==b[:-1]or x==b[:-1]or x==b[1:]or x==b)
Python 3.8, (削除) 273 (削除ここまで) \$\cdots\$(削除) 321 (削除ここまで) 316 bytes
Added 30 bytes to fix bugs kindly pointed out by Bubbler.
Added 12 bytes to fix a bug kindly pointed out by ovs.
Saved 5 bytes thanks to ovs!!!
def f(*x,i=0):
b,a=w=sorted(x,key=len);d,c=map(len,w)
while a[i]==b[i]:
if i==d-1:return i==c-3
i+=1
while a[c-1]==b[d-1]:
if d==1:return c==3
c-=1;d-=1
a=a[i:c]
b=b[i:d]
return c-i>1 and((x:=a[1:-1])==(y:=b[1:-1])or a[:-1]==y or a[1:]==y or a[:-1]==b[1:]or a[1:]==b[:-1]or x==b[:-1]or x==b[1:]or x==b)
Python 3.8, (削除) 273 (削除ここまで) \$\cdots\$(削除) 316 (削除ここまで) 312 bytes
Added 30 bytes to fix bugs kindly pointed out by Bubbler.
Added 12 bytes to fix a bug kindly pointed out by ovs.
Saved 9 bytes thanks to ovs!!!
def f(*x,i=0):
b,a=w=sorted(x,key=len);d,c=map(len,w)
while a[i]==b[i]:
if(i:=i+1)==d:return i==c-4
while a[c-1]==b[d-1]:
if d==1:return c==3
c-=1;d-=1
a=a[i:c]
b=b[i:d]
return c-i>1and((x:=a[1:-1])==(y:=b[1:-1])or a[:-1]==y or a[1:]==y or a[:-1]==b[1:]or a[1:]==b[:-1]or x==b[:-1]or x==b[1:]or x==b)
Python 3.8, (削除) 273 (削除ここまで) \$\cdots\$(削除) 309321 (削除ここまで) 321316 bytes
Added 30 bytes to fix bugs kindly pointed out by Bubbler.
Added 12 bytes to fix a bug kindly pointed out by ovs.
Saved 5 bytes thanks to ovs !!!
def f(a*x,bi=0):
cb,d=lena=w=sorted(a)x,len(bkey=len)
if c<d:b,a,d,c=a,b;d,cc=map(len,d
i=0w)
while a[i]==b[i]:
if i==d-1:return i==c-3
i+=1
while a[c-1]==b[d-1]:
if d==1:return c==3
c-=1;d-=1
a=a[i:c]
b=b[i:d]
return c-i>1 and((x:=a[1:-1])==(y:=b[1:-1])or a[:-1]==y or a[1:]==y or a[:-1]==b[1:]or a[1:]==b[:-1]or x==b[:-1]or x==b[1:]or x==b)
Python 3.8, (削除) 273 (削除ここまで) \$\cdots\$(削除) 309 (削除ここまで) 321 bytes
Added 30 bytes to fix bugs kindly pointed out by Bubbler.
Added 12 bytes to fix a bug kindly pointed out by ovs.
def f(a,b):
c,d=len(a),len(b)
if c<d:b,a,d,c=a,b,c,d
i=0
while a[i]==b[i]:
if i==d-1:return i==c-3
i+=1
while a[c-1]==b[d-1]:
if d==1:return c==3
c-=1;d-=1
a=a[i:c]
b=b[i:d]
return c-i>1 and((x:=a[1:-1])==(y:=b[1:-1])or a[:-1]==y or a[1:]==y or a[:-1]==b[1:]or a[1:]==b[:-1]or x==b[:-1]or x==b[1:]or x==b)
Python 3.8, (削除) 273 (削除ここまで) \$\cdots\$(削除) 321 (削除ここまで) 316 bytes
Added 30 bytes to fix bugs kindly pointed out by Bubbler.
Added 12 bytes to fix a bug kindly pointed out by ovs.
Saved 5 bytes thanks to ovs !!!
def f(*x,i=0):
b,a=w=sorted(x,key=len);d,c=map(len,w)
while a[i]==b[i]:
if i==d-1:return i==c-3
i+=1
while a[c-1]==b[d-1]:
if d==1:return c==3
c-=1;d-=1
a=a[i:c]
b=b[i:d]
return c-i>1 and((x:=a[1:-1])==(y:=b[1:-1])or a[:-1]==y or a[1:]==y or a[:-1]==b[1:]or a[1:]==b[:-1]or x==b[:-1]or x==b[1:]or x==b)