-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
44 lines (35 loc) · 1.06 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
author = RATIARIVELO Nekena Rayane
version = 1.0.0
"""
class Solver:
children_data: dict[str, tuple[str]]
candy_data: dict[str, int]
def __init__(self, children_data, candy_data):
self.candy_data = candy_data
self.children_data = children_data
def solve(self):
solution = {}
for children in self.children_data.keys():
solution[children] = {}
for candy in self.children_data[children]:
if self.candy_data[candy] == 0:
continue
solution[children][candy] = 1
self.candy_data[candy] -= 1
return solution
if __name__ == "__main__":
children_data = {
"Alice": ("Chocolat", "Guimauve"),
"Bob": ("Caramel", "Fruits"),
"Charlie": ("Chocolat", "Caramel"),
}
candy_data = {
"Chocolat": 10,
"Caramel": 8,
"Guimauve": 5,
"Fruits": 6,
}
solver = Solver(children_data, candy_data)
print(solver.solve())
# print(len(solver.solutions), solver.solutions[1])