Python 3, (削除) 600 (削除ここまで) (削除) 548 (削除ここまで) (削除) 503 (削除ここまで) (削除) 458 (削除ここまで) (削除) 358 (削除ここまで) (削除) 349 (削除ここまで) (削除) 346 (削除ここまで) 326 bytes
lambda n,s:p(s,q(s,(0,1,1,1.2)[n],(1,0.5,3,5)[n]),n)
q=lambda s,p,q:int(p/2+(p*p/4+len(s)/q)**0.5)
g=lambda s,j,i,c,n=1,l=[]:s and-~i and g(s[i:],j,i+(-1,1,0)[(2,1,n<j,(n<j*2-1)+(0<=n-j<j-1))[c]],c,n+1,l+[s[:i]])or l
p=lambda s,k,c:"\n".join([" ".join(i).center(k*(1,(2,4)[c>1])[c>0]-2)for i in g(s,(0,k)[c>1],(k,0)[c==1],c)])
I Know it is a bit long but i want to commit it and improve it over time...
The inputs are:
0 = Triangle
1 = square
2 = Hexagon
3 = Octagon
Thanks to:
- @caird coinheringaahing for saving 2 bytes
Paul-B98
- 583
- 4
- 12