points by ecdavis 4 years ago

Years ago I challenged you on this and you suggested I write a simulation to check. I did just that and my understanding of the problem improved dramatically. That exchange made a pretty big impact on me and is something I think about fairly often, so thanks. :)

https://news.ycombinator.com/item?id=9079260

hypertele-Xii 4 years ago

I also wrote a simulation, in PHP, when I first encountered this problem.

  <?php
  $wins = 0;
  for ($i = 0; $i < 1000; $i ++)
   {
   $car = mt_rand(0, 2);
   $choose = mt_rand(0, 2);
   if ($choose == $car) $wins ++;
   }
  echo "stay: " . ($wins / 1000 * 100) . "%<br />";
  // switch
  $wins = 0;
  for ($i = 0; $i < 1000; $i ++)
   {
   $car = mt_rand(0, 2);
   $choose = mt_rand(0, 2);
   if ($choose != $car) $wins ++;
   }
  echo "switch: " . ($wins / 1000 * 100) . "%";