Dragon curve by twobit

i=input()
w=[28,33,65][i%3]
p=[565,1198,2707][i%3]
f=([" "]*~-w+["\n"])*p
r=3
s=[1]
exec's+=[1]+s;s[r-1]=3;r*=2;'*~-i
for c in[0,1]+s:r+=c;p+=[w,1,-w,-1][r%4];f[p]="*"
print"".join(f)

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

download

return to the top page