Created
May 26, 2016 08:54
-
-
Save tgfuellner/b52bdfd202f051955756185b87c72ca3 to your computer and use it in GitHub Desktop.
Who has to serve in Table Tennis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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