- Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcount_seq.py
More file actions
Latest commit
37 lines (30 loc) · 543 Bytes
/
Copy pathcount_seq.py
File metadata and controls
37 lines (30 loc) · 543 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
defcount_seq():
n='2'
whileTrue:
yieldint(n)
next_value=''
whilelen(n)>0:
first=n[0]
count=0
whilelen(n)>0andn[0]==first:
count+=1
n=n[1:]
next_value+='{}{}'.format(count,first)
n=next_value
if__name__=='__main__':
gen=count_seq()
foriinrange(10):
print(next(gen))
"""
[실행 결과]
2
12
1112
3112
132112
1113122112
311311222112
13211321322112
1113122113121113222112
31131122211311123113322112
"""