Skip to content

Instantly share code, notes, and snippets.

@gnyman

gnyman/try1.py Secret

Created December 3, 2022 18:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save gnyman/134436e7007593d72b6a7666a3a2082e to your computer and use it in GitHub Desktop.
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