# Probability of winning.

There is a game with three types of cards.

Win cards, If you get one of these, you win.

Lose card, if you get this, you lose.

Revive card: If you get one of these, you draw another card.

Now Initially we have a deck of cards of all three types. p Win cards, q Lose cards, and r revive cards. The deck is well shuffled.

Then we take the first s cards of the deck ( s < p + q ) and discard them. What is the probability That I would win the game now.

This is an excercise from my book. How do we approach this problem?

• "This is an excercise from my book", really, I thought you got tricked trying to solve codechef.com/JULY13/problems/PROB @admin, bring this post down, its a question from live contest. – AdhogCrusher Jul 8 '13 at 21:34

The probability that the first win card comes before the first lose card is unchanged at $\dfrac{p}{p+q}$.
Let $P(W)$ be the probability of winning and let $P_i(L)$ be the probability of drawing a lose card at the $i$th trial and let $P_j(R)$ be the probability of drawing a revive card at the $j$th trial. Then
$P(W) = 1 - \sum_{i=1}^N P_i (L)\prod_{j=1}^{i-1} P_j(R)$
where $N=r+1$