Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Divide Gold: Rates Are Rising by Magu
def winner_share(gold: int, sailors: int) -> int:
if not (gold % (sailors + 2)):
return int(gold / (sailors + 2) * 2) # Captain's double share, no kills
elif not (gold % sailors):
return int(gold / sailors) # The crew makes a riot against Captain
else:
for i in range(1, sailors):
if not (gold % (sailors - i + 2)):
return int(gold / (sailors - i + 2) * 2) # Captain starts to kill sailors
return gold # Captain kills all and take all gold
Sept. 19, 2024