Skip to content

Commit 6df242d

Browse files
committed
implemented forced allocation
1 parent 08c30f9 commit 6df242d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

laptop_alloctaion.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,14 @@ def allocate_laptops(
105105
laptops_copy.remove(laptop)
106106
sadness += index
107107
break
108-
elif laptop.operating_system != person.preferred_operating_system[
109-
index
110-
] and index + 1 == len(person.preferred_operating_system):
111-
sadness += 100
108+
# If after distribution person still doesn't have a laptop, give him the first we can find
109+
if person not in allocation:
110+
allocation[person] = laptops[0]
111+
sadness += 100
112112

113113
return allocation
114+
115+
116+
allocation = allocate_laptops(users, laptops)
117+
print("\n".join(f"{key} :\n {value}" for key, value in allocation.items()))
118+
print(sadness)

0 commit comments

Comments
 (0)