1class LockPicker_2MI0600229:
2 def __init__(self, lock):
3 self.lock = lock
4
5 def unlock(self):
6 args = []
7
8 while True:
9 try:
10 if self.lock.pick(*args):
11 return
12
13 except TypeError as exception:
14 if exception.position is None:
15 args = [0] * exception.expected
16 else:
17 args[exception.position - 1] = exception.expected()
18
19 except ValueError as exception:
20 args[exception.position - 1] = exception.expected
Резултат от контролното:
23/25 верни отговора.
19 точки.
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
f | 1 | class LockPicker_2MI0600229: | f | 1 | class LockPicker_2MI0600229: |
2 | def __init__(self, lock): | 2 | def __init__(self, lock): | ||
3 | self.lock = lock | 3 | self.lock = lock | ||
4 | 4 | ||||
5 | def unlock(self): | 5 | def unlock(self): | ||
6 | args = [] | 6 | args = [] | ||
7 | 7 | ||||
8 | while True: | 8 | while True: | ||
t | 9 | print(args) | t | ||
10 | try: | 9 | try: | ||
11 | if self.lock.pick(*args): | 10 | if self.lock.pick(*args): | ||
12 | return | 11 | return | ||
13 | 12 | ||||
14 | except TypeError as exception: | 13 | except TypeError as exception: | ||
15 | if exception.position is None: | 14 | if exception.position is None: | ||
16 | args = [0] * exception.expected | 15 | args = [0] * exception.expected | ||
17 | else: | 16 | else: | ||
18 | args[exception.position - 1] = exception.expected() | 17 | args[exception.position - 1] = exception.expected() | ||
19 | 18 | ||||
20 | except ValueError as exception: | 19 | except ValueError as exception: | ||
21 | args[exception.position - 1] = exception.expected | 20 | args[exception.position - 1] = exception.expected |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | class LockPicker_2MI0600229: | f | 1 | class LockPicker_2MI0600229: |
2 | def __init__(self, lock): | 2 | def __init__(self, lock): | ||
3 | self.lock = lock | 3 | self.lock = lock | ||
4 | 4 | ||||
5 | def unlock(self): | 5 | def unlock(self): | ||
6 | args = [] | 6 | args = [] | ||
7 | 7 | ||||
8 | while True: | 8 | while True: | ||
9 | print(args) | 9 | print(args) | ||
10 | try: | 10 | try: | ||
11 | if self.lock.pick(*args): | 11 | if self.lock.pick(*args): | ||
t | 12 | print("les get") | t | ||
13 | return | 12 | return | ||
14 | 13 | ||||
15 | except TypeError as exception: | 14 | except TypeError as exception: | ||
16 | if exception.position is None: | 15 | if exception.position is None: | ||
17 | args = [0] * exception.expected | 16 | args = [0] * exception.expected | ||
18 | else: | 17 | else: | ||
19 | args[exception.position - 1] = exception.expected() | 18 | args[exception.position - 1] = exception.expected() | ||
20 | 19 | ||||
21 | except ValueError as exception: | 20 | except ValueError as exception: | ||
22 | args[exception.position - 1] = exception.expected | 21 | args[exception.position - 1] = exception.expected |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|