Skip to content

Commit 3b8395a

Browse files
authored
Create count_seq.py
1 parent e56196f commit 3b8395a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

count_seq.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
def count_seq():
2+
n='2'
3+
while True:
4+
yield int(n)
5+
next_value=''
6+
7+
while len(n)>0:
8+
first=n[0]
9+
count=0
10+
11+
while len(n)>0 and n[0]==first:
12+
count+=1
13+
n=n[1:]
14+
15+
next_value+='{}{}'.format(count,first)
16+
17+
n=next_value
18+
19+
if __name__ == '__main__':
20+
gen=count_seq()
21+
22+
for i in range(10):
23+
print(next(gen))

0 commit comments

Comments
 (0)