Merge pull request #5 from TiagoRG/dev-tiagorg

This commit is contained in:
Tiago Garcia 2023-02-06 14:57:14 +00:00 committed by GitHub
commit 18f60e322e
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:") print("a) Table of common interests:")
commoninterests = {(p1, p2): interests[p1].intersection(interests[p2]) commoninterests = {(p1, p2): interests[p1].intersection(interests[p2])
for p1 in interests for p2 in interests 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(commoninterests)
print("b) Maximum number of common interests:") print("b) Maximum number of common interests:")

View File

@ -20,11 +20,12 @@ def unload(t, m, q):
for v in t[::-1]: for v in t[::-1]:
if v[0] != m: if v[0] != m:
continue continue
while v[1] > 0 and q > 0: if v[1] <= q:
v[1] -= 1 q -= v[1]
q -= 1
if v[1] == 0:
t.remove(v) t.remove(v)
else:
v[1] -= q
q = 0
return q return q