Comment

Comment by TekMol

Shorter version:

    chanceOfHead=0.9;
    heads=0;
    tails=0;
    flips=0;
    while(flips<1000)
    {
     coin1=Math.random()<chanceOfHead;
     coin2=Math.random()<chanceOfHead;
     if(coin1==coin2) continue;
     heads+=coin1;
     tails+=coin2;
     flips++;
    };
    console.log(heads,tails);
parent TekMol 9 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton