Show possible solutions for: All levels; level: previous, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, next
http://www.pythonchallenge.com/pc/return/bull.html
import itertools
def look_and_say (length):
table = {
("1", "1", "1"): "31",
("1", "1"): "21",
("1", ): "11",
("2", "2", "2"): "32",
("2", "2"): "22",
("2", ): "12",
("3", "3", "3"): "33",
("3", "3"): "23",
("3", ): "13"
}
prec, result = "1", [1]
for i in xrange(length - 1):
prec = "".join(table[tuple(l)] for e, l in itertools.groupby(prec))
result.append(int(prec))
return result
print len(str(look_and_say(31)[30]))