Skip to main content
added 15 characters in body
Source Link
Jitse
  • 7.7k
  • 3
  • 19
  • 43

Python 3, 6572 bytes

f=lambda a,n:(a[-n:]inn]in a[a[1:-1]])*a[*a[n:-n]or]or max((f(a+cc+a,n)for c in{*a}),key=len)

Try it online!Try it online!

Python 3, 65 bytes

f=lambda a,n:(a[-n:]in a[:-1])*a[:-n]or max(f(a+c,n)for c in{*a})

Try it online!

Python 3, 72 bytes

f=lambda a,n:(a[:n]in a[1:])*a[n:]or max((f(c+a,n)for c in{*a}),key=len)

Try it online!

Source Link
Jitse
  • 7.7k
  • 3
  • 19
  • 43

Python 3, 65 bytes

f=lambda a,n:(a[-n:]in a[:-1])*a[:-n]or max(f(a+c,n)for c in{*a})

Try it online!