Calculate different sequence of scores in a Volleyball match

2 teams play a match of Volleyball

During the course of the game, each team gets points, and thus increases its score by 1.

The initial score is 0 for both teams.

The game ends when:

  • One of the teams gets 25 points and another team has < 24 points (
    strictly less than 24).
  • If the score ties at 24:24, the teams
    continue to play until the absolute difference between the scores is

Given the final score of a game in the format A:*B* i.e., the first team has scored A points and the second has scored B points, can you print the number of different sequences of getting points by teams that leads to this final score?

Solutions Collecting From Web of "Calculate different sequence of scores in a Volleyball match"

Yes, that is possible. Hint: for an arbitrary standing A:B, where it is not clear who made the last point, there are $\binom{A+B}{A}$ possibilities, if both A and B are below 25.

if one of them is equal to or more than 25, then there are some exceptions.

Case 1: 25:B with B<24, then we know the last point was from the winning team, so there are $\binom{24+B}{B}$ possibilities

case 2: B+2:B with B>23, then we know that at one point it was 24:24, so we have $\binom{48}{24} 2^{B-24}$ possibilites, because there are two options every two points.

Here’s a recursive programming solution in pseudo-code

Define NumScores(A,B):

If A=0 and B=0, return 1
Else If A<0 or B<0, return 0
Else If A<25 and B<25, return NumScores(A-1,B) + NumScores(A,B-1)
Else If |A-B|>1, return 0
Else return NumScores(A-1,B) + NumScores(A,B-1)

This should work so long as for your initial input for A and B you subtract 1 from the winning score, since that was the only possible previous score.