Python Challenge level 10: “where are you looking at”
Level 10 doesn’t have anything new.
Hint 1: len(a[30]) = ?
Hint 2: a = [1, 11, 21, 1211, 111221,
Fact 1: 'a' is the 'look and say sequence'.
Im normally pretty good finding numeric patterns, but I must confess that I had to look up this one. I suppose I don't have the right mindset to mix numbers and words.
a=['1']
for i in range(30):
elem=a[-1]+’?’
next=[]
start=0
for end in range(len(elem)):
if elem[end]!=elem[start]:
next.append(str(end-start)+elem[start])
start=end
a.append(”.join(next))
print len(a[-1])
The output is:
5808
That's it. Coming up next, Level 11.