Skip to content

Instantly share code, notes, and snippets.

@juanmacuevas
Created July 22, 2015 22:22
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 juanmacuevas/b897d70d2bf599135905 to your computer and use it in GitHub Desktop.
Save juanmacuevas/b897d70d2bf599135905 to your computer and use it in GitHub Desktop.
def conway(s):
res = []
i=0
while i<len(s):
symbol = s[i]
count = i
while i<len(s) and s[i]==symbol:
i= i+1
count = i - count
res.append([count,symbol])
print res
def co(s):
s = str(s)
res = ""
i=0
while i<len(s):
symbol = s[i]
count = i
while i<len(s) and s[i]==symbol:
i= i+1
count = i - count
res+=str(count)
res+=str(symbol)
return int(res)
def co_deep(level,input):
loop = 0
prev = input
while loop<level:
print
print prev
prev = co(prev)
loop = loop+1
def coBin(s):
res = ""
i=0
while i<len(s):
symbol = s[i]
count = i
while i<len(s) and s[i]==symbol:
i = i+1
count = i - count
res+="{0:b}".format(count)
res+=symbol
return res
def coBin_deep(level,input):
loop = 0
prev = input
while loop<level:
print prev+"\t"+str(int(prev, 2))
prev = coBin(prev)
loop = loop+1
coBin_deep(10,'1')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment