Skip to content

Instantly share code, notes, and snippets.

@sedkis
Last active February 6, 2020 02:14
Show Gist options
  • Save sedkis/9dfe8f3b4d9481a08d8e90941f00eeb0 to your computer and use it in GitHub Desktop.
Save sedkis/9dfe8f3b4d9481a08d8e90941f00eeb0 to your computer and use it in GitHub Desktop.
// 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