Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Simple equations only ... solution in Clear category for Championship Table by salukim
Data = tuple[int, int, int, int, int]
def results(data: Data) -> Data:
G,P,W,D,L = data
while -1 in [G,P,W,D,L]: # iterate until all found
if -1 not in [W,D,L] : G = W + D + L # games from win, draws and losses
if -1 not in [G,D,L] : W = G - D - L # wins from games, draws and losses
if -1 not in [G,W,D] : L = G - D - W # losses from games, draws and wins
if -1 not in [G,W,L] : D = G - W - L # draws from games, wins and losses
if -1 not in [W,D] : P = 3*W + D # points from wins and draws
if -1 not in [P,W] : D = P - 3*W # draws from points and wins
if -1 not in [P,D] : W = (P - D)//3 # wins from points and draws
if -1 not in [G,P,L] : W = (P + L - G)/2 # wins from points, losses and and games
return (G,P,W,D,L)
print("Example:")
print(results([10, 20, 6, 2, -1]))
# These "asserts" are used for self-checking
assert results((10, 20, 6, 2, -1)) == (10, 20, 6, 2, 2)
assert results((-1, 64, 18, 10, 10)) == (38, 64, 18, 10, 10)
assert results((-1, 47, 14, -1, 9)) == (28, 47, 14, 5, 9)
print("The mission is done! Click 'Check Solution' to earn rewards!")
Oct. 11, 2024
Comments: