FP: Simplifications
This commit is contained in:
parent
2b733f8d04
commit
9924af2844
|
@ -21,7 +21,7 @@ def main():
|
|||
print("a) Table of common interests:")
|
||||
commoninterests = {(p1, p2): interests[p1].intersection(interests[p2])
|
||||
for p1 in interests for p2 in interests
|
||||
if p1 != p2 and list(interests.keys()).index(p1) < list(interests.keys()).index(p2)}
|
||||
if list(interests.keys()).index(p1) < list(interests.keys()).index(p2)}
|
||||
print(commoninterests)
|
||||
|
||||
print("b) Maximum number of common interests:")
|
||||
|
|
|
@ -20,11 +20,12 @@ def unload(t, m, q):
|
|||
for v in t[::-1]:
|
||||
if v[0] != m:
|
||||
continue
|
||||
while v[1] > 0 and q > 0:
|
||||
v[1] -= 1
|
||||
q -= 1
|
||||
if v[1] == 0:
|
||||
if v[1] <= q:
|
||||
q -= v[1]
|
||||
t.remove(v)
|
||||
else:
|
||||
v[1] -= q
|
||||
q = 0
|
||||
return q
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue