Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 4 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47

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)

Try it online! Try it online!

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)

Try it online!

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)

Try it online!

deleted 7 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47

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)

Try it online! Try it online!

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)

Try it online!

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)

Try it online!

added 78 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47

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)

Try it online! Try it online!

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)

Try it online!

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)

Try it online!

added 144 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
deleted 44 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
added 3 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
deleted 42 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
deleted 46 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
deleted 1215 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
added 31 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
edited body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
edited body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
edited body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
added 151 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
deleted 15 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
added 36 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
added 132 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
added 19 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
added 10 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
added 1013 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
added 6 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
deleted 3 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
added 200 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
added 34 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
added 43 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47
Loading
1
2

AltStyle によって変換されたページ (->オリジナル) /