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 58 characters in body
Source Link
Chas Brown
  • 9.8k
  • 1
  • 14
  • 39

Python 2, (削除) 176 (削除ここまで) (削除) 170 (削除ここまで) (削除) 165 (削除ここまで) (削除) 161 (削除ここまで) 157 bytes

g=lambda a,r:r and g(map(''.join,zip(*a))[::-1],r-1)or a
R=['#']
n=1
exec"R=g([' '+l for l in g(R,n)][:-1]+[(n+2)*'#'],3*n);n+=1;"*input()
print'\n'.join(R)

Try it online!

Repeatedly: Uses g to rotate the nth iteration of the spiral into a 'canonical' position (similar to N=3 or N=7), adds a new segment by adding 2 spaces at the left of each existing row, then replacing the last row with all '#'s (resulting in a position comparable to N=4 or N=8), and finally using g again to rotate it back to the correct position. Lather, rinse, repeat.

Python 2, (削除) 176 (削除ここまで) (削除) 170 (削除ここまで) (削除) 165 (削除ここまで) (削除) 161 (削除ここまで) 157 bytes

g=lambda a,r:r and g(map(''.join,zip(*a))[::-1],r-1)or a
R=['#']
n=1
exec"R=g([' '+l for l in g(R,n)][:-1]+[(n+2)*'#'],3*n);n+=1;"*input()
print'\n'.join(R)

Try it online!

Uses g to rotate the spiral into a 'canonical' position (similar to N=3 or N=7), adds a new segment by adding 2 spaces at the left of each existing row, then replacing the last row with all '#'s (resulting in a position comparable to N=4 or N=8), and finally using g again to rotate it back to the correct position.

Python 2, (削除) 176 (削除ここまで) (削除) 170 (削除ここまで) (削除) 165 (削除ここまで) (削除) 161 (削除ここまで) 157 bytes

g=lambda a,r:r and g(map(''.join,zip(*a))[::-1],r-1)or a
R=['#']
n=1
exec"R=g([' '+l for l in g(R,n)][:-1]+[(n+2)*'#'],3*n);n+=1;"*input()
print'\n'.join(R)

Try it online!

Repeatedly: Uses g to rotate the nth iteration of the spiral into a 'canonical' position (similar to N=3 or N=7), adds a new segment by adding 2 spaces at the left of each existing row, then replacing the last row with all '#'s (resulting in a position comparable to N=4 or N=8), and finally using g again to rotate it back to the correct position. Lather, rinse, repeat.

added 14 characters in body
Source Link
Chas Brown
  • 9.8k
  • 1
  • 14
  • 39

Python 2, (削除) 176 (削除ここまで) (削除) 170 (削除ここまで) (削除) 165 (削除ここまで) (削除) 161 (削除ここまで) 157 bytes

g=lambda a,r:r and g(map(''.join,zip(*a))[::-1],r-1)or a
R=['#']
n=1
exec"R=g([' '+l for l in g(R,n)][:-1]+[(n+2)*'#'],3*n);n+=1;"*input()
print'\n'.join(R)

Try it online!

Uses g to rotate the spiral into a 'canonical' position (similar to N=3 or N=7), adds a new segment by adding 2 spaces at the left of each existing row, then replacing the last row with all '#'s (resulting in a position comparable to N=4 or N=8), and finally using g again to rotate it back to the correct position.

Python 2, (削除) 176 (削除ここまで) (削除) 170 (削除ここまで) (削除) 165 (削除ここまで) (削除) 161 (削除ここまで) 157 bytes

g=lambda a,r:r and g(map(''.join,zip(*a))[::-1],r-1)or a
R=['#']
n=1
exec"R=g([' '+l for l in g(R,n)][:-1]+[(n+2)*'#'],3*n);n+=1;"*input()
print'\n'.join(R)

Try it online!

Uses g to rotate the spiral into a 'canonical' position (similar to N=3), adds a new segment by adding 2 spaces at the left of each existing row, then replacing the last row with all '#'s (resulting in a position comparable to N=4), and finally using g again to rotate it back to the correct position.

Python 2, (削除) 176 (削除ここまで) (削除) 170 (削除ここまで) (削除) 165 (削除ここまで) (削除) 161 (削除ここまで) 157 bytes

g=lambda a,r:r and g(map(''.join,zip(*a))[::-1],r-1)or a
R=['#']
n=1
exec"R=g([' '+l for l in g(R,n)][:-1]+[(n+2)*'#'],3*n);n+=1;"*input()
print'\n'.join(R)

Try it online!

Uses g to rotate the spiral into a 'canonical' position (similar to N=3 or N=7), adds a new segment by adding 2 spaces at the left of each existing row, then replacing the last row with all '#'s (resulting in a position comparable to N=4 or N=8), and finally using g again to rotate it back to the correct position.

added 2 characters in body
Source Link
Chas Brown
  • 9.8k
  • 1
  • 14
  • 39

Python 2, (削除) 176 (削除ここまで) (削除) 170 (削除ここまで) (削除) 165 (削除ここまで) 161(削除) 161 (削除ここまで) 157 bytes

g=lambda a,r:r and g(map(''.join,zip(*a))[::-1],r-1)or a
R=['#']
n=1
exec"T=['exec"R=g([' '+l for l in g(R,n)];R=g(T[][:-1]+[(n+2)*'#'],3*n);n+=1;"*input()
print'\n'.join(R)

Try it online! Try it online!

Uses g to rotate the spiral into ana 'canonical' position (similar to N=3), adds a new segment by adding 2 spaces at the left of each existing row, then areplacing the last row ofwith all '#'s at the bottom (resulting in a position comparable to N=4), then usesand finally using g again to rotate it back to the correct position.

Python 2, (削除) 176 (削除ここまで) (削除) 170 (削除ここまで) (削除) 165 (削除ここまで) 161 bytes

g=lambda a,r:r and g(map(''.join,zip(*a))[::-1],r-1)or a
R=['#']
n=1
exec"T=[' '+l for l in g(R,n)];R=g(T[:-1]+[(n+2)*'#'],3*n);n+=1;"*input()
print'\n'.join(R)

Try it online!

Uses g to rotate the spiral into an 'canonical' position (similar to N=3), adds a new segment by adding 2 spaces at the left of each existing row, then a row of all '#'s at the bottom (resulting in a position comparable to N=4), then uses g again to rotate it back.

Python 2, (削除) 176 (削除ここまで) (削除) 170 (削除ここまで) (削除) 165 (削除ここまで) (削除) 161 (削除ここまで) 157 bytes

g=lambda a,r:r and g(map(''.join,zip(*a))[::-1],r-1)or a
R=['#']
n=1
exec"R=g([' '+l for l in g(R,n)][:-1]+[(n+2)*'#'],3*n);n+=1;"*input()
print'\n'.join(R)

Try it online!

Uses g to rotate the spiral into a 'canonical' position (similar to N=3), adds a new segment by adding 2 spaces at the left of each existing row, then replacing the last row with all '#'s (resulting in a position comparable to N=4), and finally using g again to rotate it back to the correct position.

added 177 characters in body
Source Link
Chas Brown
  • 9.8k
  • 1
  • 14
  • 39
Loading
added 98 characters in body
Source Link
Chas Brown
  • 9.8k
  • 1
  • 14
  • 39
Loading
deleted 7 characters in body
Source Link
Chas Brown
  • 9.8k
  • 1
  • 14
  • 39
Loading
added 19 characters in body
Source Link
Chas Brown
  • 9.8k
  • 1
  • 14
  • 39
Loading
added 17 characters in body
Source Link
Chas Brown
  • 9.8k
  • 1
  • 14
  • 39
Loading
Source Link
Chas Brown
  • 9.8k
  • 1
  • 14
  • 39
Loading

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