Крет Вячеслав Александрович, 321 группа LookSay 8955 | Казимагамедов Тагир 424 LookSay 8896 | ||||
---|---|---|---|---|---|
n | 1 | from itertools import * | n | 1 | from itertools import groupby |
2 | 2 | ||||
3 | def LookSay(): | 3 | def LookSay(): | ||
n | 4 | ans = '1' | n | 4 | curr_ans = '1' |
5 | while True: | 5 | while True: | ||
n | 6 | for i in ans: | n | 6 | for el in curr_ans: |
7 | yield int(i) | 7 | yield int(el) | ||
8 | new_ans = '' | 8 | new_ans = '' | ||
t | 9 | for i, j in groupby(ans): | t | 9 | for i, group in groupby(curr_ans): |
10 | new_ans += f'{len(list(j))}{i}' | 10 | new_ans += f'{len(list(group))}{i}' | ||
11 | ans = new_ans | 11 | curr_ans = new_ans |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|