Skip to content

Commit 76f824d

Browse files
Validate laptop availability before allocation
1 parent a0b9fcd commit 76f824d

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

laptop_allocation/laptop_allocation.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ def calculate_sadness(person:Person, laptop:Laptop)-> int:
9999
# ============================================================================
100100

101101
def allocate_laptops(people: List[Person], laptops: List[Laptop]) -> Dict[Person,Laptop]:
102+
if len(laptops) < len(people):
103+
raise ValueError("Not enough laptops to allocate one per person")
104+
102105
result={}
103106
available_laptops = laptops.copy()
104107

0 commit comments

Comments
 (0)