We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9ffb839 commit 658bbdbCopy full SHA for 658bbdb
1 file changed
implement-laptop-allocation/main.py
@@ -36,7 +36,7 @@ def sadness(person: Person, laptop: Laptop) ->int:
36
def allocate_laptops(people: List[Person], laptops: List[Laptop]) -> Dict[Person, Laptop]:
37
38
best_scenario_assignment = None
39
- best_scenario_sadness = float("inf")
+ best_total_sadness = float("inf")
40
41
for scenario in scenarios(laptops):
42
total_sadness = 0
@@ -45,3 +45,9 @@ def allocate_laptops(people: List[Person], laptops: List[Laptop]) -> Dict[Person
45
for person, laptop in zip(people, scenario):
46
total_sadness += sadness(person, laptop)
47
48
+ #Check if this is the best scenario so far
49
+ if total_sadness < best_total_sadness:
50
+ best_total_sadness = total_sadness
51
+ best_scenario_assignment = scenario
52
+
53
0 commit comments