Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Cup Stage by freeman_lex
from math import ceil
def cup_stage(pos1: int, pos2: int, total: int) -> str:
k = 2
while ceil(pos1/k) != ceil(pos2/k): k *= 2
return (f"1/{total//k}", "final")[total == k]
print("Example:")
print(cup_stage(5, 10, 16))
# These "asserts" are used for self-checking
assert cup_stage(10, 14, 16) == "1/2"
assert cup_stage(5, 18, 32) == "final"
assert cup_stage(5, 7, 8) == "1/2"
assert cup_stage(1, 2, 2) == "final"
assert cup_stage(13, 14, 32) == "1/16"
print("The mission is done! Click 'Check Solution' to earn rewards!")
June 21, 2025
Comments: