Last active
January 24, 2018 16:37
-
-
Save jcchurch/bd88cd98c5b8420b70620782e8e81ebd to your computer and use it in GitHub Desktop.
Ulam Spiral in Python 3 in less than 280 characters. Small enough to tweet!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as t | |
d=500 | |
w=t.Canvas(t.Tk(),width=d,height=d) | |
w.pack() | |
x=d/2;y=x;v=1;z=0;c=2;r=1;p=[] | |
for i in range(2,d*200): | |
x+=v;y+=z | |
if r*2==c:z=v;v=0 | |
if r==c:v=-z;z=0;c+=2;r=0 | |
r+=1;t=1 | |
for s in p: | |
if i%s==0:t=0;break | |
if t==1:p+=[i];w.create_arc(x,y,x,y) | |
w.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment