1class LockPicker_6MI0600300:
2 def __init__(self, lock):
3 self.lock = lock
4
5 def unlock(self):
6 args = []
7 while True:
8 try:
9 if self.lock.pick(*args):
10 return args
11 except Exception as ex:
12 if isinstance(ex, TypeError):
13 if ex.position is None:
14 required_args = ex.expected
15 args = [None] * required_args
16 else:
17 wrong_index = ex.position - 1
18 new_type = ex.expected
19 try:
20 args[wrong_index] = new_type(args[wrong_index])
21 except TypeError:
22 args[wrong_index] = new_type()
23 elif isinstance(ex, ValueError):
24 wrong_index = ex.position - 1
25 new_value = ex.expected
26 args[wrong_index] = new_value
Резултат от контролното:
18/25 верни отговора.
15 точки.
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
13.11.2024 16:07
13.11.2024 16:12