1DEFAULT_VALUES = {
2 bool : False, int : 0, float : 0.0,
3 complex : 0j, str : '', list : [],
4 tuple : tuple(), dict : {}, set : set()
5} # Fingers crossed it works :D
6
7class LockPicker_2MI0600305:
8
9 def __init__(self, lock):
10 self.lock = lock
11
12 def unlock(self):
13
14 valid_args = []
15
16 while True:
17 try:
18 if self.lock.pick(*valid_args):
19 return True
20 except TypeError as err:
21 if err.position is None:
22 valid_args.extend([None] * err.expected)
23 elif isinstance(err.position, int):
24 valid_args[err.position - 1] = DEFAULT_VALUES[err.expected]
25 except ValueError as err:
26 valid_args[err.position - 1] = err.expected
Резултат от контролното:
19/25 верни отговора.
16 точки.
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
13.11.2024 16:15
13.11.2024 16:16