program test (output); var a,b,c,d,e,ct:integer; function CountEq (x1,x2,x3,x4,x5:integer): integer; {Finds how many of five integers are equal} var ck, j,k,max:integer; Toss : array[1..5] of Integer; begin Toss[1]:=x1; Toss[2]:=x2; Toss[3]:=x3; Toss[4]:=x4; Toss[5]:=x5; max:=0; for j:=1 to 5 do begin ck:=0; for k:=1 to 5 do if (Toss[j]=Toss[k]) then ck:=ck+1; if ck>max then max:=ck; end; CountEq:=max end; {end of CountEq} {******************************* main ************************************} begin for a:=1 to 6 do for b:=1 to 6 do for c:=1 to 6 do for d:=1 to 6 do for e:=1 to 6 do if (CountEq(a,b,c,d,e)=4) then begin writeLn(a,b,c,d,e); ct:=ct+1 end; writeLn ('Counted ', ct, ' four-of-a-kid'); end.