Last active
May 9, 2022 11:17
-
-
Save mutatrum/a75b128ff2bac985beba6aac8c92d77e to your computer and use it in GitHub Desktop.
Monty Hodlonaut
This file contains hidden or 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
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)}`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?