6 kyu

Give the status of the tennis game

Description:

Anna and Bob are playing tennis, they want you to show the result of their game.

A game is won when a player scores four (or more) points: 15, 30, 40 and the game-winning point.

Should both players make it 40, then the score is called "DEUCE". Following deuce, a player must win two consecutive points: the first point, known as "advantage" and the game-winning point. *IMPORTANT : If the opposing player scores the next point when the player has the advantage, the game once again heads to deuce.

  • 1 point = 15
  • 2 points = 30
  • 3 points = 40
  • 40-40 = Deuce
  • Server wins deuce point = Ad-In
  • Receiver wins deuce point = Ad-Out

Array wins is given like following : wins = ["Anna","Bob","Anna"] (should return "Bob 15, Anna 30", Bob always goes first). Note that wins is never an empty array.

Write a function get_status(wins) which returns the result as a string as following :

  • "DEUCE" when there is Deuce (40-40, or like said above)
  • "30a" when both players have 30 and "15a" when both players have 15
  • "Anna ADVANTAGE" when there is Deuce and Anna (for example) has scored
  • "Bob WINS" when Bob (for example) has the advantage and scored
  • or simply "Bob 15, Anna 30" for other cases

*NOTE : When a player has won, even if the other player has scored after, the winner is the winner (ex: get_status(["Bob","Anna","Bob","Anna","Bob","Anna","Bob","Bob","Anna"]) should return "Bob WINS")

Games
Algorithms

Stats:

CreatedMay 23, 2022
PublishedMay 23, 2022
Warriors Trained196
Total Skips2
Total Code Submissions638
Total Times Completed67
Python Completions67
Total Stars7
% of votes with a positive feedback rating88% of 26
Total "Very Satisfied" Votes20
Total "Somewhat Satisfied" Votes6
Total "Not Satisfied" Votes0
Total Rank Assessments16
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • reneravoala Avatar
  • mauro-1 Avatar
  • dfhwze Avatar
Ad