1class LockPicker_6MI0600341:
2 def __init__(self, lock):
3 self.lock = lock
4
5 def unlock(self):
6 arguments_in_pick = []
7 while True:
8 try:
9 if self.lock.pick(*arguments_in_pick):
10 return
11 except Exception as current_exception:
12 if isinstance(current_exception, TypeError) and current_exception.position is None:
13 arguments_in_pick = [None] * current_exception.expected
14 elif isinstance(current_exception, TypeError):
15 arguments_in_pick[current_exception.position - 1] = current_exception.expected()
16 elif isinstance(current_exception, ValueError):
17 arguments_in_pick[current_exception.position - 1] = current_exception.expected
18 else:
19 raise current_exception
Резултат от контролното:
19/25 верни отговора.
16 точки.
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
f | 1 | class LockPicker_6MI0600341: | f | 1 | class LockPicker_6MI0600341: |
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 | arguments_in_pick = [] | 6 | arguments_in_pick = [] | ||
7 | while True: | 7 | while True: | ||
8 | try: | 8 | try: | ||
9 | if self.lock.pick(*arguments_in_pick): | 9 | if self.lock.pick(*arguments_in_pick): | ||
10 | return | 10 | return | ||
11 | except Exception as current_exception: | 11 | except Exception as current_exception: | ||
12 | if isinstance(current_exception, TypeError) and current_exception.position is None: | 12 | if isinstance(current_exception, TypeError) and current_exception.position is None: | ||
t | 13 | arguments_in_pick = [None] * current_exception.position | t | 13 | arguments_in_pick = [None] * current_exception.expected |
14 | elif isinstance(current_exception, TypeError): | 14 | elif isinstance(current_exception, TypeError): | ||
15 | arguments_in_pick[current_exception.position - 1] = current_exception.expected() | 15 | arguments_in_pick[current_exception.position - 1] = current_exception.expected() | ||
16 | elif isinstance(current_exception, ValueError): | 16 | elif isinstance(current_exception, ValueError): | ||
17 | arguments_in_pick[current_exception.position - 1] = current_exception.expected | 17 | arguments_in_pick[current_exception.position - 1] = current_exception.expected | ||
18 | else: | 18 | else: | ||
19 | raise current_exception | 19 | raise current_exception |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|