Advertisement
Guest User

Boy Girl Problem

a guest
May 28th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function codeforESL() {
  2.     const kekNUT = ["Gold", "Silver"]
  3.     const yourMomsBox = [];
  4.  
  5.     function shieet() {
  6.         return Math.random() > 0.5 ? 0 : 1;
  7.     }
  8.  
  9.     function NUT() {
  10.         return kekNUT[shieet()];
  11.     }
  12.  
  13.     // A magical Egyption frog god randomly chooses either a gold or a silver orb and places the orb in a box
  14.     yourMomsBox.push(NUT());
  15.  
  16.     // He again chooses another orb that is also randomly either gold or silver and places it in the same box
  17.     yourMomsBox.push(NUT());
  18.  
  19.     // There are now two orbs in the box, each of which can be either gold or silver.
  20.     // console.log(yourMomsBox.length);
  21.  
  22.     // You did not see him choose the orbs, and you cannot see into the box.
  23.     // However, a Jewish rabbi with an extraordinary sense of smell, informs you that he can detect the scent of gold coming from that box.
  24.     // This tells you that there is at least one golden orb in side the box.
  25.     yourMomsBox[shieet()] = "Gold";
  26.     return yourMomsBox;
  27. }
  28.  
  29. function its50Percent() {
  30.     let bothGold = 0;
  31.     let N = 1000000
  32.     for (let index = 0; index < N; index++) {
  33.         const [leftNUT, rightNUT] = codeforESLFags();
  34.         if (leftNUT === "Gold" && rightNUT === "Gold") {
  35.             bothGold++;
  36.         }
  37.     }
  38.     console.log(`${bothGold} out of ${N} are gold. ${bothGold / N}`);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement