Level 10
点击图片中的牛,转到sequence.txt,写着a = [1, 11, 21, 1211, 111221,
查了一下,是一个叫做外观数列的东西。求len(a[30]) = ?
a = ['1', '11', '21', '1211', '111221']
while len(a) < 31:
last = a[-1]
new = []
amount = 0
number = last[0]
for n in last:
if n == number:
amount += 1
else:
new.append(str(amount)+number)
number = n
amount = 1
new.append(str(amount)+number)
ch = ''
for n in new:
ch += n
a.append(ch)
print len(a[30])
得到len(a[30]) = 5808。