FP: Simplifications

This commit is contained in:
TiagoRG 2023-02-06 13:54:23 +00:00
parent 283b0f8e72
commit 4457deb525
Signed by untrusted user who does not match committer: TiagoRG
GPG Key ID: DFCD48E3F420DB42
2 changed files with 6 additions and 5 deletions

View File

@ -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:")

View File

@ -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