Skip to main content
Commonmark migration
Source Link

#Python, 188 bytes#

Python, 188 bytes

Mathematically calculates the character at each x,y position. It was tricky making the +s print on both sides of each box as well as stopping the rightmost +s of what would be n+1th boxes.

n=input();l=1;c=0
for y in range(n*n,-1,-1):
 s=""
 for x in range((n*n+n)/2+1):k=((8*x+1)**.5+1)/2;i=int(k);b=y<=i**2;s+=" |-+"[((k==i)+2*((y%l+c)*(y%i+(k==n+1))<1))*b];l=i;c=b^1
 print s

#Python, 188 bytes#

Mathematically calculates the character at each x,y position. It was tricky making the +s print on both sides of each box as well as stopping the rightmost +s of what would be n+1th boxes.

n=input();l=1;c=0
for y in range(n*n,-1,-1):
 s=""
 for x in range((n*n+n)/2+1):k=((8*x+1)**.5+1)/2;i=int(k);b=y<=i**2;s+=" |-+"[((k==i)+2*((y%l+c)*(y%i+(k==n+1))<1))*b];l=i;c=b^1
 print s

Python, 188 bytes

Mathematically calculates the character at each x,y position. It was tricky making the +s print on both sides of each box as well as stopping the rightmost +s of what would be n+1th boxes.

n=input();l=1;c=0
for y in range(n*n,-1,-1):
 s=""
 for x in range((n*n+n)/2+1):k=((8*x+1)**.5+1)/2;i=int(k);b=y<=i**2;s+=" |-+"[((k==i)+2*((y%l+c)*(y%i+(k==n+1))<1))*b];l=i;c=b^1
 print s
Source Link
KSab
  • 6.7k
  • 2
  • 20
  • 31

#Python, 188 bytes#

Mathematically calculates the character at each x,y position. It was tricky making the +s print on both sides of each box as well as stopping the rightmost +s of what would be n+1th boxes.

n=input();l=1;c=0
for y in range(n*n,-1,-1):
 s=""
 for x in range((n*n+n)/2+1):k=((8*x+1)**.5+1)/2;i=int(k);b=y<=i**2;s+=" |-+"[((k==i)+2*((y%l+c)*(y%i+(k==n+1))<1))*b];l=i;c=b^1
 print s