Created
July 22, 2015 22:22
-
-
Save juanmacuevas/b897d70d2bf599135905 to your computer and use it in GitHub Desktop.
This file contains 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
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 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