use strict;
my $trials = 10000;

my $stay = 0;
my $switch = 0;

foreach (1 .. $trials)
{
   my $prize = int(rand 3);
    
   my $chosen = int(rand 3);
    
   my $show;
   do { $show = int(rand 3) } while $show == $chosen || $show == $prize;
    
    
   $stay++ if $prize == $chosen;
    
   $switch++ if $prize == 3 - $chosen - $show;
    
    
    
}

print "Stay win ratio " .  (100.0 * $stay/$trials) . "\n";
print "Switch win ratio " . (100.0 * $switch/$trials) . "\n";