3 Doors 1 Car 2 Goats

public class Main {nanny-goat
    private static Logger logger = Logger.getLogger("Random");
     public static void main(String[] args) {
        String[] coins = {"L", "L", "W"};
        Random r = new Random();
        double total = 0;
        double win = 0;
        for(int i=0; i<100; i++) {
          int fc = r.nextInt(3);
          String fcs = coins[fc];
          // always swap
          if(fcs.equals("W")) {
              // loss
          } else {
              win++;
          }
          total++;
        }
        logger.info("win percentage: " + win/total);
    }
}

Leave a comment