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 Revisions

1 of 11
Paul-B98
  • 583
  • 4
  • 12

Python 3, 600 bytes

f=lambda n,s:(a(s),b(s),c(s),d(s))[n]
q=lambda s,i,l=[]:s and q(s[i:],i,l+[s[:i]])or l
t=lambda s,l=[],i=1:s and t(s[i:],l+[s[:i]],i+1)or l
h=lambda s,j,i,n=1,l=[]:s and i and h(s[i:],j,(i-1,i+1)[n<j],n+1,l+[s[:i]])or l
o=lambda s,j,i,n=1,l=[]:s and i and o(s[i:],j,(i-1,i,i+1)[(n<j)+(n<j*2-1)],n+1,l+[s[:i]])or l
p=lambda l,c:"\n".join([" ".join(i).center(c) for i in l])
def a(s):k=int(len(s)**0.5);return p(q(s,k),k)
def b(s):l=t(s);*_,k=l;return p(l,len(k)*2)
def c(s):k=int(0.5+(0.25+(-~len(s)//3))**0.5);return p(h(s,k,k),k*4-2)
def d(s):k=int(0.6+(1.44+len(s)/5)**0.5);return p(o(s,k,k),k*4-2)

Try it online!

I Know it is a bit long but i want to commit it and improve it over time...

Paul-B98
  • 583
  • 4
  • 12

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