Last active
February 6, 2020 02:14
-
-
Save sedkis/9dfe8f3b4d9481a08d8e90941f00eeb0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If you have a 50% chance of winning combined with a 40% chance of winning | |
// It is the same as having a 90% chance of winning combined with a 0 percent chance of winning | |
percentOfWin = 0.5; | |
percentOfWinTwo = 0.4; | |
totalWins = 0; | |
n = 100000; | |
while (n > 0) { | |
// First Draw | |
if (Math.random() <= percentOfWin) | |
totalMoney++ | |
// Second Draw | |
if (Math.random() <= percentOfWinTwo) | |
totalMoney++ | |
n-- | |
} | |
// Should give ~90% win rate, or (n * .9) | |
print(totalWins) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment