-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest.py
More file actions
62 lines (40 loc) · 1.32 KB
/
test.py
File metadata and controls
62 lines (40 loc) · 1.32 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# This is a example file
# try to make a private repl with this command:
# ---------------------------
#
# python -m CryptMyRepl "./test.py"
#
# ---------------------------
# follow the instructions and done!
from typing import Iterable, Iterator, Any
class Infiniterator:
def __init__(self, iterable: Iterable) -> None:
self.iterable: Iterable = tuple(iterable)
self._index: int = 0
def __iter__(self) -> Iterator:
yield from self.iterable
def __len__(self) -> int:
return len(self.iterable)
def __next__(self) -> Any:
self._index += 1
if len(self) <= (self._index - 1):
self._index = 1
n = list(self)[self._index - 1]
return n
def seek(self, offset: int) -> None:
if offset >= len(self):
raise ValueError(f'offset cannot be equal or > of len(self)')
self._index = offset
def __mod__(self, other: int) -> Iterator:
new = self.__class__(self)
n = []
for _ in range(other):
n.append(next(new))
yield from n
abc: Infiniterator = Infiniterator('ABC')
count: int = 9
new: Iterator = list(abc % 9)
print(' '.join(new))
print(' '.join('^' * count))
print(' '.join('123456789'))
input()