Skip to content

Instantly share code, notes, and snippets.

@kade-robertson
Created July 2, 2015 20:05
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 kade-robertson/d7e2c14975ef45063455 to your computer and use it in GitHub Desktop.
Save kade-robertson/d7e2c14975ef45063455 to your computer and use it in GitHub Desktop.
def splt(s):
switch = s[0]
out = switch
for i in xrange(1, len(s)):
if s[i] == switch:
out += s[i]
else:
out += ' '+s[i]
switch = s[i]
return out
def main():
n = 30
m = 0
o = '0'
f = open('temp.txt','w')
f.write('0 0\r\n')
while m < n:
m += 1
r = splt(o).split()
o = ''
for x in r:
c = bin(len(x))[2:]
v = x[:1]
o += c+v
f.write(`m`+' '+o+'\n')
f.close()
print "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment