Skip to content

Instantly share code, notes, and snippets.

@littlebtc

littlebtc/psg.py Secret

Created September 26, 2020 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save littlebtc/6db6b72a3efb8f236eb3900cd596b4b3 to your computer and use it in GitHub Desktop.
Save littlebtc/6db6b72a3efb8f236eb3900cd596b4b3 to your computer and use it in GitHub Desktop.
{'UOL': [2, 0], 'PSG': [2, 1], 'V3': [1, 1], 'R7': [1, 2], 'LGD': [0, 2]}
V3 > LGD
R7 > UOL
PSG > V3
UOL > LGD
[('UOL', [3, 1]), ('PSG', [3, 1]), ('V3', [2, 2]), ('R7', [2, 2]), ('LGD', [0, 4])]
---------------------
V3 > LGD
R7 > UOL
PSG > V3
LGD > UOL
[('PSG', [3, 1]), ('UOL', [2, 2]), ('V3', [2, 2]), ('R7', [2, 2]), ('LGD', [1, 3])]
---------------------
V3 > LGD
R7 > UOL
V3 > PSG
UOL > LGD
[('UOL', [3, 1]), ('V3', [3, 1]), ('PSG', [2, 2]), ('R7', [2, 2]), ('LGD', [0, 4])]
---------------------
V3 > LGD
R7 > UOL
V3 > PSG
LGD > UOL
[('V3', [3, 1]), ('UOL', [2, 2]), ('PSG', [2, 2]), ('R7', [2, 2]), ('LGD', [1, 3])]
---------------------
V3 > LGD
UOL > R7
PSG > V3
UOL > LGD
[('UOL', [4, 0]), ('PSG', [3, 1]), ('V3', [2, 2]), ('R7', [1, 3]), ('LGD', [0, 4])]
---------------------
V3 > LGD
UOL > R7
PSG > V3
LGD > UOL
[('UOL', [3, 1]), ('PSG', [3, 1]), ('V3', [2, 2]), ('R7', [1, 3]), ('LGD', [1, 3])]
---------------------
V3 > LGD
UOL > R7
V3 > PSG
UOL > LGD
[('UOL', [4, 0]), ('V3', [3, 1]), ('PSG', [2, 2]), ('R7', [1, 3]), ('LGD', [0, 4])]
---------------------
V3 > LGD
UOL > R7
V3 > PSG
LGD > UOL
[('UOL', [3, 1]), ('V3', [3, 1]), ('PSG', [2, 2]), ('R7', [1, 3]), ('LGD', [1, 3])]
---------------------
LGD > V3
R7 > UOL
PSG > V3
UOL > LGD
[('UOL', [3, 1]), ('PSG', [3, 1]), ('R7', [2, 2]), ('V3', [1, 3]), ('LGD', [1, 3])]
---------------------
LGD > V3
R7 > UOL
PSG > V3
LGD > UOL
[('PSG', [3, 1]), ('UOL', [2, 2]), ('R7', [2, 2]), ('LGD', [2, 2]), ('V3', [1, 3])]
---------------------
LGD > V3
R7 > UOL
V3 > PSG
UOL > LGD
[('UOL', [3, 1]), ('PSG', [2, 2]), ('V3', [2, 2]), ('R7', [2, 2]), ('LGD', [1, 3])]
---------------------
LGD > V3
R7 > UOL
V3 > PSG
LGD > UOL
[('UOL', [2, 2]), ('PSG', [2, 2]), ('V3', [2, 2]), ('R7', [2, 2]), ('LGD', [2, 2])]
---------------------
LGD > V3
UOL > R7
PSG > V3
UOL > LGD
[('UOL', [4, 0]), ('PSG', [3, 1]), ('V3', [1, 3]), ('R7', [1, 3]), ('LGD', [1, 3])]
---------------------
LGD > V3
UOL > R7
PSG > V3
LGD > UOL
[('UOL', [3, 1]), ('PSG', [3, 1]), ('LGD', [2, 2]), ('V3', [1, 3]), ('R7', [1, 3])]
---------------------
LGD > V3
UOL > R7
V3 > PSG
UOL > LGD
[('UOL', [4, 0]), ('PSG', [2, 2]), ('V3', [2, 2]), ('R7', [1, 3]), ('LGD', [1, 3])]
---------------------
LGD > V3
UOL > R7
V3 > PSG
LGD > UOL
[('UOL', [3, 1]), ('PSG', [2, 2]), ('V3', [2, 2]), ('LGD', [2, 2]), ('R7', [1, 3])]
---------------------
from copy import deepcopy
from itertools import product
TEAMS = {
'UOL': [2, 0],
'PSG': [2, 1],
'V3': [1, 1],
'R7': [1, 2],
'LGD': [0, 2]
}
REMAINING = [
('V3', 'LGD'),
('R7', 'UOL'),
('PSG', 'V3'),
('UOL', 'LGD')
]
# Posibility will be an array with 0 and 1
print(TEAMS)
POSSIBILITIES = product(range(2), repeat=len(REMAINING))
for possibility in POSSIBILITIES:
result = deepcopy(TEAMS)
for index, match in enumerate(REMAINING):
if possibility[index] == 0:
print(f'{match[0]} > {match[1]}')
result[match[0]][0] += 1
result[match[1]][1] += 1
else:
print(f'{match[1]} > {match[0]}')
result[match[1]][0] += 1
result[match[0]][1] += 1
print(sorted(result.items(), key=lambda team: team[1][0], reverse=True))
print('---------------------')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment