PROGRAM   ZIEGENPROBLEM;

{The Monty Hall Problem gets its name from the TV game show, Lets Make A Deal, hosted by Monty Hall1. The scenario is such: you are given the opportunity to select one closed door of three, behind one of which there is a prize. The other two doors hide goats (or some other such nonprize), or nothing at all. Once you have made your selection, Monty Hall will open one of the remaining doors, revealing that it does not contain the prize2. He then asks you if you would like to switch your selection to the other unopened door, or stay with your original choice. Here is the problem: Does it matter if you switch?}
//Uses crt;

var  i,n,j,m, cr,cw: Integer;
     house,first,moderator,change: Integer;
     repinput: string;                   {of yes and now}


FUNCTION zufall:Integer;
Begin
  result:= Random(3) + 1;              {three doors}
End;

PROCEDURE Input (Var zahl1,zahl2:Integer);
    Begin
    Writeln('');
    zahl1:= strtoint(readln('How many shows do you want?:'));
    Writeln('How many runs, (the statistic significant run is about 900) ?:');
    zahl2:= strtoint(readln('How many runs, significant is about 900'))
    //Readln(zahl2);
    End;

PROCEDURE Print;
  Begin
    Writeln('  the change was successfull in  ' + inttostr(cr) +'  runs');
    Writeln('              but no success in  ' + inttostr(cw) +'  runs')
  End;

PROCEDURE Show;
    Begin
       Randomize;
           house:= zufall;
           first:= zufall;
               Repeat
                 moderator:= zufall;
               Until (moderator<>house) And (moderator<>first);
           change:= 6 - moderator - first;
               If change = house
                 Then cr:= cr+1
                 Else cw:= cw+1;
    End;

BEGIN                            {main}
//Clrscr;
     Repeat;
     n:=0;
     m:=0;
     Input(n,m);
           For i:= 0 to n-1 do begin
             cr:=0;
             cw:=0;
               For j:= 1 to m do begin
                 Show;
               End;  {for j}
            Print    
           End;         {for i}
         Writeln('');
         Writeln('  new simulation?  (y/n) ');
         repinput:= Readln('  new simulation?  (y/n) ');
     Until(repinput= 'n') Or (repinput= 'N')
END.