1class LockPicker_0MI0600152:
2 def __init__(self, lock):
3 self._lock = lock
4 self._args = []
5
6 def unlock(self):
7 while(True):
8 try:
9 self._lock.pick(*self._args)
10 break
11 except Exception as ex:
12 if issubclass(ex.__class__, TypeError) and ex.position is None:
13 self.__generate_args(ex.expected)
14 elif issubclass(ex.__class__, TypeError):
15 self.__generate_valid_type(ex.expected, ex.position)
16 elif issubclass(ex.__class__, ValueError):
17 self.__generate_valid_value(ex.expected, ex.position)
18
19 def __generate_args(self, number_of_args):
20 self._args = [None] * number_of_args
21
22 def __generate_valid_type(self, _type, position):
23 self._args[position - 1] = _type()
24
25 def __generate_valid_value(self, value, position):
26 self._args[position - 1] = value
Резултат от контролното:
24/25 верни отговора.
20 точки.
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
13.11.2024 19:43