File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
implement-laptop-allocation Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ def sadness(person: Person, laptop: Laptop) ->int:
3636def allocate_laptops (people : List [Person ], laptops : List [Laptop ]) -> Dict [Person , Laptop ]:
3737
3838 best_scenario_assignment = None
39- best_scenario_sadness = float ("inf" )
39+ best_total_sadness = float ("inf" )
4040
4141 for scenario in scenarios (laptops ):
4242 total_sadness = 0
@@ -45,3 +45,9 @@ def allocate_laptops(people: List[Person], laptops: List[Laptop]) -> Dict[Person
4545 for person , laptop in zip (people , scenario ):
4646 total_sadness += sadness (person , laptop )
4747
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+
You can’t perform that action at this time.
0 commit comments