1

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 2.

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?

Jaguar
  • 485

2 Answers2

4

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.

supinf
  • 13,433
  • If A = 3 and B = 25, the number of sequences will be 2925. Can u please explain how this comes? – Jaguar May 21 '15 at 17:52
  • 1
    Since one is 25 and the other is less than 24, use case of of supinf's solution. $\binom{24+3}{3}$ – Bob Krueger May 21 '15 at 17:56
  • ignoring the last point, there are 27 Points played in total, and three of them from player A. so we look for the number of possibilities on how to choose 3 elements among 27, that is $\binom{27}{3}$ per definition of the binomial coefficient. – supinf May 21 '15 at 17:58
  • Can you, please, explain case 2: 1) why we are taking 48C24 binom coefficient ? 2) why 2.pow(b-24) is used ? I do not get math fundamentals under the hood. I understand only, that for all case where A=25 and B<24 we calculate binomial coefficient(a number from pascal triangle). Thank you! – Dzmitry Kashlach May 23 '23 at 09:08
1

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.

Bob Krueger
  • 6,226