Beta

Table tennis: Who's serving?

Description:

Your colleagues enjoy playing table tennis, but they often forget who should serve in each round. They ask you to create a program that will determine the serving player based on the current round number.

Rules

  • The game starts with the first round, or currentRound=1.
  • Player 1 always starts the game by serving.
  • A serving player alternates every two rounds
  • currentRound cannot be a negative number or zero
  • The original game rules are simplified: there is no "deuce" exception (service does not alternate at every point after '10-10')

Examples

  • The Player 1 serves in the 1st round
  • The Player 1 serves in the 2nd round
  • The Player 2 serves in the 3rd round
  • The Player 2 serves in the 4th round
  • The Player 1 serves in the 5th round
  • The Player 1 serves in the 6tx round
  • The Player 2 serves in the 7th round
  • The Player 2 serves in the 8th round
  • And so on
Mathematics

Stats:

CreatedFeb 1, 2025
PublishedFeb 1, 2025
Warriors Trained11
Total Skips0
Total Code Submissions31
Total Times Completed11
Go Completions11
Total Stars1
% of votes with a positive feedback rating70% of 5
Total "Very Satisfied" Votes3
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes1
Total Rank Assessments5
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • sergei-kustov Avatar
Ad