ve.lomonosova LookSay 9117 | Иван Загребин, ФКИ м106 LookSay 9090 | ||||
---|---|---|---|---|---|
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 | res = '1' |
5 | while True: | 5 | while True: | ||
t | 6 | for i in current: | t | 6 | for digit in res: |
7 | yield int(i) | 7 | yield int(digit) | ||
8 | current = ''.join([f'{len(list(count))}{elem}' for elem, count in groupby(current)]) | 8 | res = ''.join((f'{len(list(g))}{k}' for k, g in groupby(res))) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|