Created
December 16, 2015 15:26
-
-
Save TimCastelijns/c8df4a627c8d586c60ea to your computer and use it in GitHub Desktop.
This file contains hidden or 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
s = '1321131112' | |
for n in xrange(0, 50): | |
chains = [] | |
chain = s[0] | |
prev = s[0] | |
part = s[1:] | |
for index, c in enumerate(part, start=1): | |
if c == prev: | |
chain += c | |
else: | |
chains.append(chain) | |
chain = c | |
prev = c | |
if index == len(part): | |
chains.append(chain) | |
s = ''.join(['{}{}'.format(len(item), item[0]) for item in chains]) | |
print 'done loop', n | |
print len(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment