| Кирилл Иванович Архипов LookSay 4849 | сян ли LookSay 5107 | ||||
|---|---|---|---|---|---|
| f | 1 | from itertools import groupby | f | 1 | from itertools import groupby |
| 2 | 2 | ||||
| 3 | def LookSay(): | 3 | def LookSay(): | ||
| n | 4 | current = '1' | n | 4 | s = '1' |
| 5 | while True: | 5 | while True: | ||
| n | 6 | for digit in current: | n | 6 | for digit in s: |
| 7 | yield int(digit) | 7 | yield int(digit) | ||
| t | 8 | next_sequence = '' | t | 8 | next_s = '' |
| 9 | for digit, group in groupby(current): | 9 | for k, g in groupby(s): | ||
| 10 | count = len(list(group)) | 10 | count = len(list(g)) | ||
| 11 | next_sequence += str(count) + digit | 11 | next_s += str(count) + k | ||
| 12 | current = next_sequence | 12 | s = next_s | ||
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||