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