Skip to content

Commit 97b72b8

Browse files
committed
Review allows spare laptop
1 parent 4bcf58e commit 97b72b8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

laptop-allocation.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ def sadness(person: Person, laptop: Laptop) -> int:
3434

3535

3636
def allocate_laptops(people: List[Person], laptops: List[Laptop]) -> Dict[Person, Laptop]:
37-
if len(people) != len(laptops):
38-
raise ValueError("Number of people must equal number of laptops.")
37+
# Every person must get a laptop; spare laptops are allowed
38+
if len(people) > len(laptops):
39+
raise ValueError("Not enough laptops for all people.")
40+
3941

4042
# Clone list so we can remove laptops as they are assigned
4143
available_laptops = laptops.copy()

0 commit comments

Comments
 (0)