@@ -51,7 +51,7 @@ class Laptop:
5151
5252def allocate_laptops (people : List [Person ], laptops : List [Laptop ]) -> Dict [str , Laptop ]:
5353 sorted_people_OS_count = sorted (people ,key = lambda p :len (p .preferred_operating_system ))
54- sadness = 0 # local variable sadness counter
54+ total_sadness = 0 # local variable sadness summer
5555 allocated_history : Dict [Person ,Laptop ] = {}
5656
5757 for person in sorted_people_OS_count :
@@ -60,7 +60,7 @@ def allocate_laptops(people: List[Person], laptops: List[Laptop]) -> Dict[str, L
6060 for laptop in laptops :
6161 if person .preferred_operating_system [i ] == laptop .operating_system :
6262 allocated_history [person .name ]= laptop # assign laptop
63- sadness += i # increment sadness by preference index
63+ total_sadness += i # increment sadness by preference index
6464 laptops .remove (laptop )
6565 allocated_flag = True
6666 break
@@ -70,9 +70,9 @@ def allocate_laptops(people: List[Person], laptops: List[Laptop]) -> Dict[str, L
7070 if not allocated_flag : # assign any remaining laptop if preferred OS not found
7171 allocated_history [person .name ]= laptops [0 ]
7272 laptops .remove (laptops [0 ])
73- sadness += 100 # high sadness for non-preferred OS
73+ total_sadness += 100 # high sadness for non-preferred OS
7474
75- return allocated_history , sadness
75+ return allocated_history , total_sadness
7676
7777def print_final_allocation (allocated_history :dict [str ,Laptop ], sadness :int ) :
7878 for name , laptop in allocated_history .items () :
0 commit comments