1class LockPicker_9MI0600401:
2 def __init__(self, lock):
3 self.lock = lock
4
5 def unlock(self):
6 args = []
7 while True:
8 try:
9 self.lock.pick(*args)
10 return #Successfully unlocked
11 except TypeError as ex:
12 if ex.position is None:
13 args = [None for _ in range(ex.expected)]
14 else:
15 args[ex.position - 1] = ex.expected()
16
17 except ValueError as ex:
18 args[ex.position - 1] = ex.expected
Резултат от контролното:
14/25 верни отговора.
12 точки.
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
f | 1 | class LockPicker_9MI0600401: | f | 1 | class LockPicker_9MI0600401: |
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 | while True: | 7 | while True: | ||
8 | try: | 8 | try: | ||
9 | self.lock.pick(*args) | 9 | self.lock.pick(*args) | ||
10 | return #Successfully unlocked | 10 | return #Successfully unlocked | ||
11 | except TypeError as ex: | 11 | except TypeError as ex: | ||
12 | if ex.position is None: | 12 | if ex.position is None: | ||
13 | args = [None for _ in range(ex.expected)] | 13 | args = [None for _ in range(ex.expected)] | ||
14 | else: | 14 | else: | ||
n | 15 | pos = ex.position - 1 | n | ||
16 | expected_type = ex.expected | ||||
17 | args[pos] = expected_type() | 15 | args[ex.position - 1] = ex.expected() | ||
18 | 16 | ||||
19 | except ValueError as ex: | 17 | except ValueError as ex: | ||
t | 20 | pos = ex.position - 1 | t | ||
21 | expected_argument = ex.expected | ||||
22 | args[pos] = expected_argument | 18 | args[ex.position - 1] = ex.expected |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | class LockPicker_9MI0600401: | f | 1 | class LockPicker_9MI0600401: |
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 | while True: | 7 | while True: | ||
8 | try: | 8 | try: | ||
t | 9 | if self.lock.pick(*args): | t | 9 | self.lock.pick(*args) |
10 | return True #Successfully unlocked | 10 | return #Successfully unlocked | ||
11 | except TypeError as ex: | 11 | except TypeError as ex: | ||
12 | if ex.position is None: | 12 | if ex.position is None: | ||
13 | args = [None for _ in range(ex.expected)] | 13 | args = [None for _ in range(ex.expected)] | ||
14 | else: | 14 | else: | ||
15 | pos = ex.position - 1 | 15 | pos = ex.position - 1 | ||
16 | expected_type = ex.expected | 16 | expected_type = ex.expected | ||
17 | args[pos] = expected_type() | 17 | args[pos] = expected_type() | ||
18 | 18 | ||||
19 | except ValueError as ex: | 19 | except ValueError as ex: | ||
20 | pos = ex.position - 1 | 20 | pos = ex.position - 1 | ||
21 | expected_argument = ex.expected | 21 | expected_argument = ex.expected | ||
22 | args[pos] = expected_argument | 22 | args[pos] = expected_argument |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|