Dragon curve by recursive

s=input()
p=[565,1198,2707][s-9]
d=C=[28,33,65][s-9]
B=list("\n".rjust(C)*53)
for n in range(2**s+1):p+=d;d=(n+n&-n-n&n<1or-1)*(-~d/C or-d*C);B[p]="*"
print"".join(B)

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page