1RESULTS = {
2 "0MI0600302": {
3 "correct": "",
4 "points": ""
5 }
6}
7
8
9class LockPicker_0MI0600302:
10 def __init__(self, lock):
11 self.lock = lock
12
13 def unlock(self):
14 args = []
15 while True:
16 try:
17 result = self.lock.pick(*args)
18 if result:
19 return args
20 except TypeError as error:
21 position = error.position
22 expected = error.expected
23 if position is None:
24 args = [None] * expected
25 else:
26 args[position - 1] = expected()
27 except ValueError as error:
28 position = error.position
29 expected = error.expected
30 args[position - 1] = expected
Резултат от контролното:
22/25 верни отговора.
18 точки.
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
n | 1 | # class NotAccurateArgsLen(TypeError): | n | 1 | RESULTS = { |
2 | # def __init__(self, message, position, expected): | 2 | "0MI0600302": { | ||
3 | # super().__init__(message) | 3 | "correct": "", | ||
4 | # self.position = position | 4 | "points": "" | ||
5 | # self.expected = expected | 5 | } | ||
6 | # | 6 | } | ||
7 | # | ||||
8 | # class NotAccurateTypeOnPosition(TypeError): | ||||
9 | # def __init__(self, message, position, expected): | ||||
10 | # super().__init__(message) | ||||
11 | # self.position = position | ||||
12 | # self.expected = expected | ||||
13 | # | ||||
14 | # | ||||
15 | # class NotAccurateValue(ValueError): | ||||
16 | # def __init__(self, message, position, expected): | ||||
17 | # super().__init__(message) | ||||
18 | # self.position = position | ||||
19 | # self.expected = expected | ||||
20 | # | ||||
21 | # | ||||
22 | # class Lock: | ||||
23 | # def __init__(self, *private_args): | ||||
24 | # self.__private_args = private_args | ||||
25 | # | ||||
26 | # def pick(self, *guess_args): | ||||
27 | # if len(self.__private_args) != len(guess_args): | ||||
28 | # raise NotAccurateArgsLen("some message", None, len(self.__private_args)) | ||||
29 | # | ||||
30 | # self.check_for_invalid_type(guess_args) | ||||
31 | # self.check_for_invalid_value(guess_args) | ||||
32 | # | ||||
33 | # return True | ||||
34 | # | ||||
35 | # def check_for_invalid_type(self, guess_args): | ||||
36 | # for i in range(len(self.__private_args)): | ||||
37 | # if type(self.__private_args[i]) is not type(guess_args[i]): | ||||
38 | # raise NotAccurateTypeOnPosition("some message", i + 1, type(self.__private_args[i])) | ||||
39 | # | ||||
40 | # def check_for_invalid_value(self, guess_args): | ||||
41 | # for i in range(len(self.__private_args)): | ||||
42 | # if self.__private_args[i] != guess_args[i]: | ||||
43 | # raise NotAccurateValue("some message", i + 1, self.__private_args[i]) | ||||
44 | 7 | ||||
45 | 8 | ||||
46 | class LockPicker_0MI0600302: | 9 | class LockPicker_0MI0600302: | ||
47 | def __init__(self, lock): | 10 | def __init__(self, lock): | ||
48 | self.lock = lock | 11 | self.lock = lock | ||
49 | 12 | ||||
50 | def unlock(self): | 13 | def unlock(self): | ||
51 | args = [] | 14 | args = [] | ||
52 | while True: | 15 | while True: | ||
53 | try: | 16 | try: | ||
54 | result = self.lock.pick(*args) | 17 | result = self.lock.pick(*args) | ||
55 | if result: | 18 | if result: | ||
56 | return args | 19 | return args | ||
57 | except TypeError as error: | 20 | except TypeError as error: | ||
58 | position = error.position | 21 | position = error.position | ||
59 | expected = error.expected | 22 | expected = error.expected | ||
60 | if position is None: | 23 | if position is None: | ||
61 | args = [None] * expected | 24 | args = [None] * expected | ||
62 | else: | 25 | else: | ||
63 | args[position - 1] = expected() | 26 | args[position - 1] = expected() | ||
64 | except ValueError as error: | 27 | except ValueError as error: | ||
65 | position = error.position | 28 | position = error.position | ||
66 | expected = error.expected | 29 | expected = error.expected | ||
67 | args[position - 1] = expected | 30 | args[position - 1] = expected | ||
t | 68 | t | |||
69 | |||||
70 | # lock = Lock("lelq ginka", 1, [1, 2, 3], ("tupulche",)) | ||||
71 | # loader = LockPicker_0MI0600302(lock) | ||||
72 | # print(loader.unlock()) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | # class NotAccurateArgsLen(TypeError): | f | 1 | # class NotAccurateArgsLen(TypeError): |
2 | # def __init__(self, message, position, expected): | 2 | # def __init__(self, message, position, expected): | ||
3 | # super().__init__(message) | 3 | # super().__init__(message) | ||
4 | # self.position = position | 4 | # self.position = position | ||
5 | # self.expected = expected | 5 | # self.expected = expected | ||
6 | # | 6 | # | ||
7 | # | 7 | # | ||
8 | # class NotAccurateTypeOnPosition(TypeError): | 8 | # class NotAccurateTypeOnPosition(TypeError): | ||
9 | # def __init__(self, message, position, expected): | 9 | # def __init__(self, message, position, expected): | ||
10 | # super().__init__(message) | 10 | # super().__init__(message) | ||
11 | # self.position = position | 11 | # self.position = position | ||
12 | # self.expected = expected | 12 | # self.expected = expected | ||
13 | # | 13 | # | ||
14 | # | 14 | # | ||
15 | # class NotAccurateValue(ValueError): | 15 | # class NotAccurateValue(ValueError): | ||
16 | # def __init__(self, message, position, expected): | 16 | # def __init__(self, message, position, expected): | ||
17 | # super().__init__(message) | 17 | # super().__init__(message) | ||
18 | # self.position = position | 18 | # self.position = position | ||
19 | # self.expected = expected | 19 | # self.expected = expected | ||
20 | # | 20 | # | ||
21 | # | 21 | # | ||
22 | # class Lock: | 22 | # class Lock: | ||
23 | # def __init__(self, *private_args): | 23 | # def __init__(self, *private_args): | ||
24 | # self.__private_args = private_args | 24 | # self.__private_args = private_args | ||
25 | # | 25 | # | ||
26 | # def pick(self, *guess_args): | 26 | # def pick(self, *guess_args): | ||
27 | # if len(self.__private_args) != len(guess_args): | 27 | # if len(self.__private_args) != len(guess_args): | ||
28 | # raise NotAccurateArgsLen("some message", None, len(self.__private_args)) | 28 | # raise NotAccurateArgsLen("some message", None, len(self.__private_args)) | ||
29 | # | 29 | # | ||
30 | # self.check_for_invalid_type(guess_args) | 30 | # self.check_for_invalid_type(guess_args) | ||
31 | # self.check_for_invalid_value(guess_args) | 31 | # self.check_for_invalid_value(guess_args) | ||
32 | # | 32 | # | ||
n | n | 33 | # return True | ||
34 | # | ||||
33 | # def check_for_invalid_type(self, guess_args): | 35 | # def check_for_invalid_type(self, guess_args): | ||
34 | # for i in range(len(self.__private_args)): | 36 | # for i in range(len(self.__private_args)): | ||
35 | # if type(self.__private_args[i]) is not type(guess_args[i]): | 37 | # if type(self.__private_args[i]) is not type(guess_args[i]): | ||
36 | # raise NotAccurateTypeOnPosition("some message", i + 1, type(self.__private_args[i])) | 38 | # raise NotAccurateTypeOnPosition("some message", i + 1, type(self.__private_args[i])) | ||
37 | # | 39 | # | ||
38 | # def check_for_invalid_value(self, guess_args): | 40 | # def check_for_invalid_value(self, guess_args): | ||
39 | # for i in range(len(self.__private_args)): | 41 | # for i in range(len(self.__private_args)): | ||
40 | # if self.__private_args[i] != guess_args[i]: | 42 | # if self.__private_args[i] != guess_args[i]: | ||
41 | # raise NotAccurateValue("some message", i + 1, self.__private_args[i]) | 43 | # raise NotAccurateValue("some message", i + 1, self.__private_args[i]) | ||
42 | 44 | ||||
43 | 45 | ||||
44 | class LockPicker_0MI0600302: | 46 | class LockPicker_0MI0600302: | ||
45 | def __init__(self, lock): | 47 | def __init__(self, lock): | ||
46 | self.lock = lock | 48 | self.lock = lock | ||
47 | 49 | ||||
48 | def unlock(self): | 50 | def unlock(self): | ||
49 | args = [] | 51 | args = [] | ||
50 | while True: | 52 | while True: | ||
51 | try: | 53 | try: | ||
52 | result = self.lock.pick(*args) | 54 | result = self.lock.pick(*args) | ||
n | n | 55 | if result: | ||
53 | return args | 56 | return args | ||
54 | except TypeError as error: | 57 | except TypeError as error: | ||
55 | position = error.position | 58 | position = error.position | ||
56 | expected = error.expected | 59 | expected = error.expected | ||
57 | if position is None: | 60 | if position is None: | ||
58 | args = [None] * expected | 61 | args = [None] * expected | ||
59 | else: | 62 | else: | ||
60 | args[position - 1] = expected() | 63 | args[position - 1] = expected() | ||
61 | except ValueError as error: | 64 | except ValueError as error: | ||
62 | position = error.position | 65 | position = error.position | ||
63 | expected = error.expected | 66 | expected = error.expected | ||
64 | args[position - 1] = expected | 67 | args[position - 1] = expected | ||
t | t | 68 | |||
69 | |||||
70 | # lock = Lock("lelq ginka", 1, [1, 2, 3], ("tupulche",)) | ||||
71 | # loader = LockPicker_0MI0600302(lock) | ||||
72 | # print(loader.unlock()) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|