Skip to content

Instantly share code, notes, and snippets.

@reflechant
Last active January 13, 2016 20:33
Show Gist options
  • Save reflechant/2d96332a40ba9f374d7f to your computer and use it in GitHub Desktop.
Save reflechant/2d96332a40ba9f374d7f to your computer and use it in GitHub Desktop.
This program draws patterns to remember if you have bought a binary watch (for example from 01theone.com)
#!/usr/bin/env python
from Tkinter import *
master = Tk()
w = Canvas(master, width=150, height=930)
#for n in range(1,61):
n = 1
for x in ( 3,6,12,24,48,7,14,28,56,15,30,60,5,10,20,40,21,42 ):
i = 0
for z, c in enumerate( "%06d" % int( bin(x)[2:] ) ):
if int(c):
f = "black"
else:
f = ""
w.create_rectangle( 15+15*i, 0+15*(n), 15+15*(i+1), 0+15*(n+1), fill=f )
i += 1
w.create_text( 15+15*(i+1)+5, 0+15*(n+1), text = x, anchor = "sw" )
n += 1
w.pack()
mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment