Last active
July 4, 2025 20:22
-
-
Save hex13/4874cf3df78f8ab50245d64e196f7126 to your computer and use it in GitHub Desktop.
drawing cards
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
const cards = [['black', 'black'], ['red', 'red'], ['red', 'black']] | |
const draw = () => cards[~~(Math.random() * 3)]; | |
var rel = 0; // relevant case count | |
var c = 0; // count of cards when we have red on the other side | |
for (let i = 0; i < 100000; i++) { | |
const [b,f] = draw(); | |
if (f == 'black'|| b=='black') { | |
rel++; | |
if (b == 'red' || f=='red') c++ | |
} | |
}; | |
console.log(`rel: ${rel}, count: ${c}, p: ${c/rel}`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment