1def function_that_says_ni(*args, **kwargs):
2 valid_shrub_names = {"храст", "shrub", "bush"}
3 total_cost = 0.0
4 shrub_names = set()
5
6 for arg in args:
7 if isinstance(arg, dict) and "name" in arg:
8 name = arg["name"].lower()
9 if name in valid_shrub_names and "cost" in arg:
10 total_cost += float(arg["cost"])
11
12
13 for key, value in kwargs.items():
14 if isinstance(value, dict) and "name" in value:
15 name = value["name"].lower()
16 if name in valid_shrub_names:
17 shrub_names.update(key)
18 if "cost" in value:
19 total_cost += float(value["cost"])
20
21 if total_cost > 42.00:
22 return "Ni!"
23
24 unique_letters = set(shrub_names)
25
26 total_cost_int = int(total_cost)
27
28 if total_cost_int == 0:
29 за return "Ni!"
30
31 if len(unique_letters) % total_cost_int != 0:
32 return "Ni!"
33
34 return f"{total_cost:.2f}лв"
35
36print(function_that_says_ni(ab={"name": "храст", "cost": 1.80}, bc={"name": "храст", "cost": 2}))
invalid syntax (solution.py, line 29)
File "/tmp/test_runner.py", line 75, in main
loaded_test = importlib.import_module('test', test_module)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/tmp/test.py", line 3, in <module>
from solution import *
Мая Панова
22.10.2024 19:34Да, грешката е изцяло моя, бързах и го качих в последния момент :(
Благодаря за двете точки все пак
|
Георги Кунчев
22.10.2024 18:50Заради доброто решение, получаваш една бонус точка.
Заради това, че имаш една тъпа грешка, но иначе тестовете ти минават на 100%, получаваш още една, утешителна.
За жалост не мога да си позволя да дам повече, защото няма да се честно спрямо останалите.
Другия път предавай по-рано, за да можем да дадем обратна връзка и да имаш време да оправиш грешките си.
Освен това, очаквам при качване на решението си, да си получила syntax error, който да те уведоми, но явно си бързала.
|
Мая Панова
22.10.2024 17:42Извинявам се, качих едно и също нещо 5 пъти, гледайте само последното
|
t | 1 | def function_that_says_ni(*args, **kwargs): | t | 1 | def function_that_says_ni(*args, **kwargs): |
2 | valid_shrub_names = {"храст", "shrub", "bush"} | 2 | valid_shrub_names = {"храст", "shrub", "bush"} | ||
3 | total_cost = 0.0 | 3 | total_cost = 0.0 | ||
4 | shrub_names = set() | 4 | shrub_names = set() | ||
5 | 5 | ||||
6 | for arg in args: | 6 | for arg in args: | ||
7 | if isinstance(arg, dict) and "name" in arg: | 7 | if isinstance(arg, dict) and "name" in arg: | ||
8 | name = arg["name"].lower() | 8 | name = arg["name"].lower() | ||
9 | if name in valid_shrub_names and "cost" in arg: | 9 | if name in valid_shrub_names and "cost" in arg: | ||
10 | total_cost += float(arg["cost"]) | 10 | total_cost += float(arg["cost"]) | ||
11 | 11 | ||||
12 | 12 | ||||
13 | for key, value in kwargs.items(): | 13 | for key, value in kwargs.items(): | ||
14 | if isinstance(value, dict) and "name" in value: | 14 | if isinstance(value, dict) and "name" in value: | ||
15 | name = value["name"].lower() | 15 | name = value["name"].lower() | ||
16 | if name in valid_shrub_names: | 16 | if name in valid_shrub_names: | ||
17 | shrub_names.update(key) | 17 | shrub_names.update(key) | ||
18 | if "cost" in value: | 18 | if "cost" in value: | ||
19 | total_cost += float(value["cost"]) | 19 | total_cost += float(value["cost"]) | ||
20 | 20 | ||||
21 | if total_cost > 42.00: | 21 | if total_cost > 42.00: | ||
22 | return "Ni!" | 22 | return "Ni!" | ||
23 | 23 | ||||
24 | unique_letters = set(shrub_names) | 24 | unique_letters = set(shrub_names) | ||
25 | 25 | ||||
26 | total_cost_int = int(total_cost) | 26 | total_cost_int = int(total_cost) | ||
27 | 27 | ||||
28 | if total_cost_int == 0: | 28 | if total_cost_int == 0: | ||
29 | за return "Ni!" | 29 | за return "Ni!" | ||
30 | 30 | ||||
31 | if len(unique_letters) % total_cost_int != 0: | 31 | if len(unique_letters) % total_cost_int != 0: | ||
32 | return "Ni!" | 32 | return "Ni!" | ||
33 | 33 | ||||
34 | return f"{total_cost:.2f}лв" | 34 | return f"{total_cost:.2f}лв" | ||
35 | 35 | ||||
36 | print(function_that_says_ni(ab={"name": "храст", "cost": 1.80}, bc={"name": "храст", "cost": 2})) | 36 | print(function_that_says_ni(ab={"name": "храст", "cost": 1.80}, bc={"name": "храст", "cost": 2})) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
t | 1 | def function_that_says_ni(*args, **kwargs): | t | 1 | def function_that_says_ni(*args, **kwargs): |
2 | valid_shrub_names = {"храст", "shrub", "bush"} | 2 | valid_shrub_names = {"храст", "shrub", "bush"} | ||
3 | total_cost = 0.0 | 3 | total_cost = 0.0 | ||
4 | shrub_names = set() | 4 | shrub_names = set() | ||
5 | 5 | ||||
6 | for arg in args: | 6 | for arg in args: | ||
7 | if isinstance(arg, dict) and "name" in arg: | 7 | if isinstance(arg, dict) and "name" in arg: | ||
8 | name = arg["name"].lower() | 8 | name = arg["name"].lower() | ||
9 | if name in valid_shrub_names and "cost" in arg: | 9 | if name in valid_shrub_names and "cost" in arg: | ||
10 | total_cost += float(arg["cost"]) | 10 | total_cost += float(arg["cost"]) | ||
11 | 11 | ||||
12 | 12 | ||||
13 | for key, value in kwargs.items(): | 13 | for key, value in kwargs.items(): | ||
14 | if isinstance(value, dict) and "name" in value: | 14 | if isinstance(value, dict) and "name" in value: | ||
15 | name = value["name"].lower() | 15 | name = value["name"].lower() | ||
16 | if name in valid_shrub_names: | 16 | if name in valid_shrub_names: | ||
17 | shrub_names.update(key) | 17 | shrub_names.update(key) | ||
18 | if "cost" in value: | 18 | if "cost" in value: | ||
19 | total_cost += float(value["cost"]) | 19 | total_cost += float(value["cost"]) | ||
20 | 20 | ||||
21 | if total_cost > 42.00: | 21 | if total_cost > 42.00: | ||
22 | return "Ni!" | 22 | return "Ni!" | ||
23 | 23 | ||||
24 | unique_letters = set(shrub_names) | 24 | unique_letters = set(shrub_names) | ||
25 | 25 | ||||
26 | total_cost_int = int(total_cost) | 26 | total_cost_int = int(total_cost) | ||
27 | 27 | ||||
28 | if total_cost_int == 0: | 28 | if total_cost_int == 0: | ||
29 | за return "Ni!" | 29 | за return "Ni!" | ||
30 | 30 | ||||
31 | if len(unique_letters) % total_cost_int != 0: | 31 | if len(unique_letters) % total_cost_int != 0: | ||
32 | return "Ni!" | 32 | return "Ni!" | ||
33 | 33 | ||||
34 | return f"{total_cost:.2f}лв" | 34 | return f"{total_cost:.2f}лв" | ||
35 | 35 | ||||
36 | print(function_that_says_ni(ab={"name": "храст", "cost": 1.80}, bc={"name": "храст", "cost": 2})) | 36 | print(function_that_says_ni(ab={"name": "храст", "cost": 1.80}, bc={"name": "храст", "cost": 2})) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
t | 1 | def function_that_says_ni(*args, **kwargs): | t | 1 | def function_that_says_ni(*args, **kwargs): |
2 | valid_shrub_names = {"храст", "shrub", "bush"} | 2 | valid_shrub_names = {"храст", "shrub", "bush"} | ||
3 | total_cost = 0.0 | 3 | total_cost = 0.0 | ||
4 | shrub_names = set() | 4 | shrub_names = set() | ||
5 | 5 | ||||
6 | for arg in args: | 6 | for arg in args: | ||
7 | if isinstance(arg, dict) and "name" in arg: | 7 | if isinstance(arg, dict) and "name" in arg: | ||
8 | name = arg["name"].lower() | 8 | name = arg["name"].lower() | ||
9 | if name in valid_shrub_names and "cost" in arg: | 9 | if name in valid_shrub_names and "cost" in arg: | ||
10 | total_cost += float(arg["cost"]) | 10 | total_cost += float(arg["cost"]) | ||
11 | 11 | ||||
12 | 12 | ||||
13 | for key, value in kwargs.items(): | 13 | for key, value in kwargs.items(): | ||
14 | if isinstance(value, dict) and "name" in value: | 14 | if isinstance(value, dict) and "name" in value: | ||
15 | name = value["name"].lower() | 15 | name = value["name"].lower() | ||
16 | if name in valid_shrub_names: | 16 | if name in valid_shrub_names: | ||
17 | shrub_names.update(key) | 17 | shrub_names.update(key) | ||
18 | if "cost" in value: | 18 | if "cost" in value: | ||
19 | total_cost += float(value["cost"]) | 19 | total_cost += float(value["cost"]) | ||
20 | 20 | ||||
21 | if total_cost > 42.00: | 21 | if total_cost > 42.00: | ||
22 | return "Ni!" | 22 | return "Ni!" | ||
23 | 23 | ||||
24 | unique_letters = set(shrub_names) | 24 | unique_letters = set(shrub_names) | ||
25 | 25 | ||||
26 | total_cost_int = int(total_cost) | 26 | total_cost_int = int(total_cost) | ||
27 | 27 | ||||
28 | if total_cost_int == 0: | 28 | if total_cost_int == 0: | ||
29 | за return "Ni!" | 29 | за return "Ni!" | ||
30 | 30 | ||||
31 | if len(unique_letters) % total_cost_int != 0: | 31 | if len(unique_letters) % total_cost_int != 0: | ||
32 | return "Ni!" | 32 | return "Ni!" | ||
33 | 33 | ||||
34 | return f"{total_cost:.2f}лв" | 34 | return f"{total_cost:.2f}лв" | ||
35 | 35 | ||||
36 | print(function_that_says_ni(ab={"name": "храст", "cost": 1.80}, bc={"name": "храст", "cost": 2})) | 36 | print(function_that_says_ni(ab={"name": "храст", "cost": 1.80}, bc={"name": "храст", "cost": 2})) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
t | 1 | def function_that_says_ni(*args, **kwargs): | t | 1 | def function_that_says_ni(*args, **kwargs): |
2 | valid_shrub_names = {"храст", "shrub", "bush"} | 2 | valid_shrub_names = {"храст", "shrub", "bush"} | ||
3 | total_cost = 0.0 | 3 | total_cost = 0.0 | ||
4 | shrub_names = set() | 4 | shrub_names = set() | ||
5 | 5 | ||||
6 | for arg in args: | 6 | for arg in args: | ||
7 | if isinstance(arg, dict) and "name" in arg: | 7 | if isinstance(arg, dict) and "name" in arg: | ||
8 | name = arg["name"].lower() | 8 | name = arg["name"].lower() | ||
9 | if name in valid_shrub_names and "cost" in arg: | 9 | if name in valid_shrub_names and "cost" in arg: | ||
10 | total_cost += float(arg["cost"]) | 10 | total_cost += float(arg["cost"]) | ||
11 | 11 | ||||
12 | 12 | ||||
13 | for key, value in kwargs.items(): | 13 | for key, value in kwargs.items(): | ||
14 | if isinstance(value, dict) and "name" in value: | 14 | if isinstance(value, dict) and "name" in value: | ||
15 | name = value["name"].lower() | 15 | name = value["name"].lower() | ||
16 | if name in valid_shrub_names: | 16 | if name in valid_shrub_names: | ||
17 | shrub_names.update(key) | 17 | shrub_names.update(key) | ||
18 | if "cost" in value: | 18 | if "cost" in value: | ||
19 | total_cost += float(value["cost"]) | 19 | total_cost += float(value["cost"]) | ||
20 | 20 | ||||
21 | if total_cost > 42.00: | 21 | if total_cost > 42.00: | ||
22 | return "Ni!" | 22 | return "Ni!" | ||
23 | 23 | ||||
24 | unique_letters = set(shrub_names) | 24 | unique_letters = set(shrub_names) | ||
25 | 25 | ||||
26 | total_cost_int = int(total_cost) | 26 | total_cost_int = int(total_cost) | ||
27 | 27 | ||||
28 | if total_cost_int == 0: | 28 | if total_cost_int == 0: | ||
29 | за return "Ni!" | 29 | за return "Ni!" | ||
30 | 30 | ||||
31 | if len(unique_letters) % total_cost_int != 0: | 31 | if len(unique_letters) % total_cost_int != 0: | ||
32 | return "Ni!" | 32 | return "Ni!" | ||
33 | 33 | ||||
34 | return f"{total_cost:.2f}лв" | 34 | return f"{total_cost:.2f}лв" | ||
35 | 35 | ||||
36 | print(function_that_says_ni(ab={"name": "храст", "cost": 1.80}, bc={"name": "храст", "cost": 2})) | 36 | print(function_that_says_ni(ab={"name": "храст", "cost": 1.80}, bc={"name": "храст", "cost": 2})) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
22.10.2024 18:46
22.10.2024 18:47
22.10.2024 18:47
22.10.2024 18:48
22.10.2024 18:48