Problem 1268. Penny flipping - calculate winning probability (easy)
Two players are playing a fair penny flipping game. For each flip, the winner adds one penny from the loser's collection to his/her collection. This continues until one player runs out of pennies and loses the game.
Calculate the probability of winning for the first player, given the first player's number of coins, m, and the second player's number of coins, n.
Example:
Input: m = 1, n =1 Output: 0.50
Solution Stats
Problem Comments
-
1 Comment
Asif Newaz
on 13 Dec 2019
https://en.wikipedia.org/wiki/Gambler%27s_ruin#Fair_coin_flipping
Solution Comments
Show commentsGroup

Probability & Stats
- 30 Problems
- 3 Finishers
- Don't be mean. Be nice!
- The Birthday Phenomenon
- Calculate the probability that at least two people in a group share the same birthday.
- The almost-birthday problem.
- Coin Tossing: Probability of Same Heads for N tosses
- Does the coin touch the line?
- Coin change combinations.
- Penny flipping - calculate winning probability (easy)
- German tank problem
- Unique dice configurations
- Throwing Dice - Will You Be Eaten By The Dragon?
- Probability of Choosing a Red Ball
- What are the odds?
- Simulating the selection of a state with given probabilities
- Generating random matrix with given probability mass function
- If you prick us, do we not bleed?
- Test Driven Solution - Probability Problem 1
- Test Driven Solution - Probability Problem 2
- Test Driven Solution - Probability Problem 3
- Probabilities - More brains than luck
- Compute Area from Fixed Sum Cumulative Probability
- Probability of red tulips (at both ends of a row)
- Cumulative probability of finding an unlikely combination
- Chess probability
- Guess the number I'm thinking of (Part 1)
- Eliminate Outliers Using Interquartile Range
- Histogram of histogram
- Given n, create n random numbers such that their standard deviation is also n.
- Mean = Standard Deviation
- Rate of event occurence: find percentiles of the distribution (for smallish rates)
Problem Recent Solvers183
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!