ПУТИЛОВ ГЕОРГИЙ КОНСТАНТИНОВИЧ PushPull 9999
Тюшев Максим, 321 PushPull 9365
t1class Pushpull:t1class Pushpull:
2    pos = 02    pos = 0
33
4    def __init__(self, p=0):4    def __init__(self, p=0):
5        Pushpull.pos = p5        Pushpull.pos = p
66
7    @staticmethod7    @staticmethod
8    def push(n=1):8    def push(n=1):
9        Pushpull.pos += n9        Pushpull.pos += n
1010
11    @staticmethod11    @staticmethod
12    def pull(n=1):12    def pull(n=1):
13        Pushpull.pos -= n13        Pushpull.pos -= n
1414
15    def __str__(self):15    def __str__(self):
16        if self.pos > 0:16        if self.pos > 0:
17            return f'>{self.pos}>'17            return f'>{self.pos}>'
18        elif self.pos < 0:18        elif self.pos < 0:
19            return f'<{-self.pos}<'19            return f'<{-self.pos}<'
20        return f'<{self.pos}>'20        return f'<{self.pos}>'
2121
22    def __iter__(self):22    def __iter__(self):
23        if self.pos > 0:23        if self.pos > 0:
24            return iter(list(range(0, self.pos)))24            return iter(list(range(0, self.pos)))
25        else:25        else:
26            return iter([-i for i in range(0, -self.pos)])26            return iter([-i for i in range(0, -self.pos)])
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op