% jleonard 3/10/02   13.002J/10.002J


% let pancake A be golden-golden
% let pancake B be golden-brown
% let pancake C be brown-brown

number_first_brown = 0;
number_second_brown = 0;
for i=1:1000
  %% we have a 1/3 probability of picking each pancake; generate a random
  %% number between 0 and  1:
  x = rand(1);

  if (x<1/3) 
    %% if we picked pancake A, there is a 0% chance that side two is brown
    %% do nothing
    
  elseif (x<2/3)
    %% if we picked pancake B, there is a 50% chance that we picked the
    %% brown side; if we picked the brown side the other side cannot be brown
    y = rand(1);
    if (y<1/2)
      number_first_brown = number_first_brown + 1;
    end
  
  else
    %% if we picked pancake C, there is a 100% chance that both sides are brown
    number_first_brown = number_first_brown + 1;
    number_second_brown = number_second_brown + 1;
  end
end

fprintf('number_first_brown = %d\n', number_first_brown);
fprintf('number_second_brown = %d\n', number_second_brown);
fprintf('ratio = %f\n', number_second_brown/number_first_brown);



