| f | def LookSay(): | f | def LookSay(): |
| n | n = '1' | n | term = '1' |
| while True: | | while True: |
| n | for digit in n: | n | for ch in term: |
| yield int(digit) | | yield int(ch) |
| next_n = '' | | next_term = '' |
| count = 1 | | count = 1 |
| n | for i in range(1, len(n)): | n | for i in range(1, len(term)): |
| if n[i] == n[i - 1]: | | if term[i] == term[i - 1]: |
| count += 1 | | count += 1 |
| else: | | else: |
| n | next_n += str(count) + n[i - 1] | n | next_term += str(count) + term[i - 1] |
| count = 1 | | count = 1 |
| t | next_n += str(count) + n[-1] | t | next_term += str(count) + term[-1] |
| n = next_n | | term = next_term |