Skip to content

Instantly share code, notes, and snippets.

@PRotondo
Created August 13, 2014 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PRotondo/08393de54a597b56a767 to your computer and use it in GitHub Desktop.
Save PRotondo/08393de54a597b56a767 to your computer and use it in GitHub Desktop.
look-and-say in binary
import itertools
def look_and_say(n) :
a = "0"
for i in xrange(n) :
b = ""
for c,l in itertools.groupby(a) :
b += bin(len(list(l)))[2:] + c
yield a
a = b
prev = 1
for i,s in enumerate(look_and_say(100)) :
# a = int(s,2)
print float(len(s)) / float(prev)
prev = len(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment