def lookandsay(line):
    p = None
    n = 0
    result = []
    for c in line:
        if n > 0 and p is not c:
            result.append(str(n))
            result.append(p)
            n = 0

        p = c
        n += 1

    result.append(str(n))
    result.append(p)

    return ''.join(result)


line = "1321131112"
for x in range(40):
    line = lookandsay(line)

print "40:", len(line)

for x in range(10):
    line = lookandsay(line)

print "50:", len(line)

import itertools

def lookandsay(line):
    return ''.join([str(len(list(it))) + c for c, it in itertools.groupby(line)])


line = "1321131112"
for x in range(40):
    line = lookandsay(line)

print "40:", len(line)

for x in range(10):
    line = lookandsay(line)

print "50:", len(line)

Reimplement day 10 using itertools combine.
Reimplement day 10 using itertools combine.

Now it DOES run using pypy, and is faster again.
