So I just finished working out a probability question which I came across on the Brilliant website, where there is a game of tennis that finishes when someone reaches four points (ignoring deuces, it's just the first person to reach 4 points). Person A has probability p to win one point, with his opponent having probability q to win (obviously q = 1 - p). The aim is to find the probability of Person A winning the entire match (this is the question here). After a while, I came up with the solution, which was correct, of the probability of Person A winning the whole match being:
$p^4 + 4p^4q+10p^4q^2 + 20p^4q^3$
However, to work out the number of permutations that existed for each different possible point distribution, I simply wrote out each one manually. EG:
$ qqpppp $, $qpqppp$, $qppqpp$,
until I had written out every permutation for that combination of p and q. My question, therefore, is this: how can you figure out the amount of different permutations without writing this all down manually. Keep in mind you cannot end the permutation with q, as as soon as p has won the 4th point the game ends.
I have given this problem multiple attempts, all of which have been unsuccessful. The closest I came was taking the number of digits and subtracting one, and then multiplying that by itself minus 1 for every instance of q in the permutation (long story short, it didn't work). If anyone can explain how to achieve this, it would be much appreciated.
Many thanks in advance.