-
-
Save gnyman/134436e7007593d72b6a7666a3a2082e to your computer and use it in GitHub Desktop.
This file contains 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 score_for_shape(shape): | |
if shape == 'X': | |
return 1 | |
if shape == 'Y': | |
return 2 | |
if shape == 'Z': | |
return 3 | |
def score_for_outcome(outcome): | |
if outcome == 'win': | |
return 6 | |
if outcome == 'draw': | |
return 3 | |
if outcome == 'loss': | |
return 0 | |
def score_for_round(opponent_shape, player_shape): | |
outcome = 'win' | |
if opponent_shape == player_shape: | |
outcome = 'draw' | |
if (opponent_shape == 'A' and player_shape == 'Z') or (opponent_shape == 'B' and player_shape == 'X') or (opponent_shape == 'C' and player_shape == 'Y'): | |
outcome = 'loss' | |
return score_for_shape(player_shape) + score_for_outcome(outcome) | |
def calculate_total_score(strategy_guide): | |
total_score = 0 | |
for round in strategy_guide: | |
total_score += score_for_round(round[0], round[1]) | |
return total_score | |
strategy_guide = [('A', 'Y'), ('B', 'X'), ('C', 'Z')] | |
print(calculate_total_score(strategy_guide)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment