Skip to content

Instantly share code, notes, and snippets.

@mutatrum
Last active May 9, 2022 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mutatrum/a75b128ff2bac985beba6aac8c92d77e to your computer and use it in GitHub Desktop.
Save mutatrum/a75b128ff2bac985beba6aac8c92d77e to your computer and use it in GitHub Desktop.
Monty Hodlonaut
BOXES = [[ '₿', '₿'], // Box A
[ '₿', '💩'], // Box B
['💩', '💩']] // Box C
var count = 0, success = 0;
while(count <= 1_000_000) {
// You choose a box at random
var drawbox = Math.floor(Math.random() * 3);
var box = BOXES[drawbox];
// and withdraw one coin at random
var drawcoin = Math.floor(Math.random() * 2);
var coin = box[drawcoin];
// if it happens to be a bitcoin
if (coin == '₿') {
// the next coin drawn from the same box
var nextcoin = box[1 - drawcoin];
// what is the chance of it also being a bitcoin?
if (nextcoin == '₿') success++;
count ++;
}
}
var percentage = (success / count) * 100;
console.log(`Odds of drawing Bitcoin: ${percentage.toFixed(2)}`)
@mutatrum
Copy link
Author

mutatrum commented May 9, 2022

https://twitter.com/hodlonaut/status/1523237743626788864

Three boxes with 2 coins each

Box a: 2 bitcoins
Box b: 1 bitcoin, 1 shitcoin
Box c: 2 shitcoins

You choose a box at random and withdraw one coin at random

Question: if it happens to be a bitcoin, what is the chance of the next coin drawn from the same box also being a bitcoin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment