Skip to content

Instantly share code, notes, and snippets.

@tgfuellner
Created May 26, 2016 08:54
Show Gist options
  • Save tgfuellner/b52bdfd202f051955756185b87c72ca3 to your computer and use it in GitHub Desktop.
Save tgfuellner/b52bdfd202f051955756185b87c72ca3 to your computer and use it in GitHub Desktop.
Who has to serve in Table Tennis
def toServe(playerTuple, sumOfPoints, game):
"""
The first player in arg playerTuple started serving
sumOfPoints of the current game
first game is 1
"""
if sumOfPoints < 20:
# First player if even
player = int(sumOfPoints / 2) % 2
else:
player = sumOfPoints % 2
# Every other game server changes
player = player + game - 1
return playerTuple[player%2]
print("aufschlag.toServe(('Tom','Sepp'), 0, 1)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment