Dragon curve by rolf

f=[[" "]*99 for i in range(99)]
S="FX"
exec'S=S.replace("X","X+yF+").replace("Y","-FX-Y").replace("y","Y");'*input()
x=y=u=0
v=1
f[50][50]="*"
for c in S:
 if c=="+":u,v=-v,u
 if c=="-":u,v=v,-u
 if c=="F":x+=u;y+=v;f[x+50][y+50]="*"
exec'f=zip(*f)[::-1]\nwhile len(set(f[0]))<2:del f[0]\n'*4   
for q in f:print"".join(q)

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

download

return to the top page