-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathround_robin.py
More file actions
39 lines (29 loc) · 833 Bytes
/
round_robin.py
File metadata and controls
39 lines (29 loc) · 833 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
38
39
#!/usr/bin/python
# coding:utf-8
'''round_robin.py
Written by akakou at 2017 08/10.
This module makes round-robin strings.
'''
from etc import character_list
import itertools
CharacterList = character_list.CharacterList
class RoundRobin(CharacterList):
'''This class is main class.'''
def setup(self):
'''Set up self data.'''
self.string = ['']
self.count = 0
def next(self):
'''Set next string and return it.'''
self.setup()
# start iterater
while True:
self.count += 1
for self.string in itertools.product(
self.character_list,
repeat=self.count
):
yield self.get_string()
def get_string(self):
'''Return self.string.'''
return ''.join(self.string)