1def function_that_says_ni(*args, **kwargs):
2 shrubs = []
3 valid_names = {"храст", "shrub", "bush"}
4
5 for item in args:
6 if type(item) is dict and "name" in item:
7 if item["name"].lower() in valid_names:
8 shrubs.append(item)
9
10 unique_letters = set()
11 for key, value in kwargs.items():
12 if type(value) is dict and "name" in value:
13 if value["name"].lower() in valid_names:
14 shrubs.append(value)
15 unique_letters.update(key)
16
17 total_sum = 0.0
18 for bush in shrubs:
19 total_sum += bush.get("cost", 0)
20
21 if total_sum > 42.00:
22 return "Ni!"
23
24 sum_in_int = int(total_sum)
25
26 if sum_in_int == 0 or (sum_in_int != 0 and len(unique_letters) % sum_in_int != 0):
27 return "Ni!"
28
29 return f"{total_sum:.2f}лв"
..........
----------------------------------------------------------------------
Ran 10 tests in 0.000s
OK
f | 1 | def function_that_says_ni(*args, **kwargs): | f | 1 | def function_that_says_ni(*args, **kwargs): |
2 | shrubs = [] | 2 | shrubs = [] | ||
3 | valid_names = {"храст", "shrub", "bush"} | 3 | valid_names = {"храст", "shrub", "bush"} | ||
4 | 4 | ||||
5 | for item in args: | 5 | for item in args: | ||
6 | if type(item) is dict and "name" in item: | 6 | if type(item) is dict and "name" in item: | ||
7 | if item["name"].lower() in valid_names: | 7 | if item["name"].lower() in valid_names: | ||
8 | shrubs.append(item) | 8 | shrubs.append(item) | ||
9 | 9 | ||||
10 | unique_letters = set() | 10 | unique_letters = set() | ||
11 | for key, value in kwargs.items(): | 11 | for key, value in kwargs.items(): | ||
12 | if type(value) is dict and "name" in value: | 12 | if type(value) is dict and "name" in value: | ||
13 | if value["name"].lower() in valid_names: | 13 | if value["name"].lower() in valid_names: | ||
14 | shrubs.append(value) | 14 | shrubs.append(value) | ||
15 | unique_letters.update(key) | 15 | unique_letters.update(key) | ||
16 | 16 | ||||
17 | total_sum = 0.0 | 17 | total_sum = 0.0 | ||
18 | for bush in shrubs: | 18 | for bush in shrubs: | ||
t | 19 | total_sum += bush.get('cost', 0) | t | 19 | total_sum += bush.get("cost", 0) |
20 | 20 | ||||
21 | if total_sum > 42.00: | 21 | if total_sum > 42.00: | ||
22 | return "Ni!" | 22 | return "Ni!" | ||
23 | 23 | ||||
24 | sum_in_int = int(total_sum) | 24 | sum_in_int = int(total_sum) | ||
25 | 25 | ||||
26 | if sum_in_int == 0 or (sum_in_int != 0 and len(unique_letters) % sum_in_int != 0): | 26 | if sum_in_int == 0 or (sum_in_int != 0 and len(unique_letters) % sum_in_int != 0): | ||
27 | return "Ni!" | 27 | return "Ni!" | ||
28 | 28 | ||||
29 | return f"{total_sum:.2f}лв" | 29 | return f"{total_sum:.2f}лв" |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | def function_that_says_ni(*args, **kwargs): | f | 1 | def function_that_says_ni(*args, **kwargs): |
2 | shrubs = [] | 2 | shrubs = [] | ||
3 | valid_names = {"храст", "shrub", "bush"} | 3 | valid_names = {"храст", "shrub", "bush"} | ||
4 | 4 | ||||
5 | for item in args: | 5 | for item in args: | ||
n | 6 | if type(item) == type(dict()) and "name" in item: | n | 6 | if type(item) is dict and "name" in item: |
7 | if item["name"].lower() in valid_names: | 7 | if item["name"].lower() in valid_names: | ||
8 | shrubs.append(item) | 8 | shrubs.append(item) | ||
9 | 9 | ||||
10 | unique_letters = set() | 10 | unique_letters = set() | ||
11 | for key, value in kwargs.items(): | 11 | for key, value in kwargs.items(): | ||
n | 12 | if type(value) == type(dict()) and "name" in value: | n | 12 | if type(value) is dict and "name" in value: |
13 | if value["name"].lower() in valid_names: | 13 | if value["name"].lower() in valid_names: | ||
14 | shrubs.append(value) | 14 | shrubs.append(value) | ||
15 | unique_letters.update(key) | 15 | unique_letters.update(key) | ||
16 | 16 | ||||
17 | total_sum = 0.0 | 17 | total_sum = 0.0 | ||
18 | for bush in shrubs: | 18 | for bush in shrubs: | ||
t | 19 | if "cost" in bush: | t | 19 | total_sum += bush.get('cost', 0) |
20 | total_sum += float(bush["cost"]) | ||||
21 | 20 | ||||
22 | if total_sum > 42.00: | 21 | if total_sum > 42.00: | ||
23 | return "Ni!" | 22 | return "Ni!" | ||
24 | 23 | ||||
25 | sum_in_int = int(total_sum) | 24 | sum_in_int = int(total_sum) | ||
26 | 25 | ||||
27 | if sum_in_int == 0 or (sum_in_int != 0 and len(unique_letters) % sum_in_int != 0): | 26 | if sum_in_int == 0 or (sum_in_int != 0 and len(unique_letters) % sum_in_int != 0): | ||
28 | return "Ni!" | 27 | return "Ni!" | ||
29 | 28 | ||||
30 | return f"{total_sum:.2f}лв" | 29 | return f"{total_sum:.2f}лв" |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | def function_that_says_ni(*args, **kwargs): | f | 1 | def function_that_says_ni(*args, **kwargs): |
2 | shrubs = [] | 2 | shrubs = [] | ||
3 | valid_names = {"храст", "shrub", "bush"} | 3 | valid_names = {"храст", "shrub", "bush"} | ||
4 | 4 | ||||
5 | for item in args: | 5 | for item in args: | ||
6 | if type(item) == type(dict()) and "name" in item: | 6 | if type(item) == type(dict()) and "name" in item: | ||
7 | if item["name"].lower() in valid_names: | 7 | if item["name"].lower() in valid_names: | ||
8 | shrubs.append(item) | 8 | shrubs.append(item) | ||
9 | 9 | ||||
10 | unique_letters = set() | 10 | unique_letters = set() | ||
11 | for key, value in kwargs.items(): | 11 | for key, value in kwargs.items(): | ||
12 | if type(value) == type(dict()) and "name" in value: | 12 | if type(value) == type(dict()) and "name" in value: | ||
13 | if value["name"].lower() in valid_names: | 13 | if value["name"].lower() in valid_names: | ||
14 | shrubs.append(value) | 14 | shrubs.append(value) | ||
15 | unique_letters.update(key) | 15 | unique_letters.update(key) | ||
16 | 16 | ||||
17 | total_sum = 0.0 | 17 | total_sum = 0.0 | ||
18 | for bush in shrubs: | 18 | for bush in shrubs: | ||
19 | if "cost" in bush: | 19 | if "cost" in bush: | ||
20 | total_sum += float(bush["cost"]) | 20 | total_sum += float(bush["cost"]) | ||
21 | 21 | ||||
22 | if total_sum > 42.00: | 22 | if total_sum > 42.00: | ||
23 | return "Ni!" | 23 | return "Ni!" | ||
24 | 24 | ||||
25 | sum_in_int = int(total_sum) | 25 | sum_in_int = int(total_sum) | ||
26 | 26 | ||||
27 | if sum_in_int == 0 or (sum_in_int != 0 and len(unique_letters) % sum_in_int != 0): | 27 | if sum_in_int == 0 or (sum_in_int != 0 and len(unique_letters) % sum_in_int != 0): | ||
28 | return "Ni!" | 28 | return "Ni!" | ||
29 | 29 | ||||
t | 30 | return f"{total_sum:.2f} лв." | t | 30 | return f"{total_sum:.2f}лв" |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|