here is some code I found

uses crt;

type

pegstype = array[1..10] of integer;

var

user,pegs,pegs2 : pegstype;

guess,x,p,c,p2,c5 : integer;

{ ----------------------------------------------------------------------------}

procedure Correct(p,c : integer; user,pegs : pegstype; var c5,p2 :

integer); { cheks if done or not }

var p3,b,c2,c3,c4 : integer;

colsc, { code colors }

colsg { colors from user }

: array[1..9] of integer;

begin

b := 0;

{ counts correct pegs }

for c2 := 1 to p do if (user[c2]=pegs[c2]) then b := b+1;

p2 := b;

{ counts correct colors }

pegs2 := pegs;

p3 := p;

{ fills COLSc with the colors in PEGS }

c4 := 0;

for c2 := 1 to c do

begin

if (pegs[c2])=c2 then

begin

c4 := c4+1;

colsc[c4] := c2;

end;

end;

{ fills COLSg with the colors in USER }

b := 0;

for c2 := 1 to c do

begin

if (user[c2]=c2) then

begin

b := b+1;

colsg[b] :=c2;

end;

end;

{ finally counts the correct colors }

c5 := 0; { says how many colors correct }

for c2 := 1 to c4 do

for c3 := 1 to b do

if colsg[c3]=colsc[c2] then c5 := c5+1;

end;

{===

=======================================================================}

Begin

clrscr;

randomize;

{ ask user how many pegs and colors to use }

write('How many pegs (1-10) -->');

readln(p);

write('How many colors (1-9) -->');

readln(c);

{ initializes the pegs }

for x := 1 to p do pegs[x] := random(c)+1;

{ starts playing the game }

guess := 1;

repeat

writeln('Guess ',guess);

for x := 1 to p do

begin

write('Peg ',x,' -->');

readln(user[x]);

end;

guess := guess+1;

correct(p,c,user,pegs,c5,p2); { calls procedure to check pegs }

writeln('You have ',p2,' correct peg(s)');

writeln('and ',c5,' correct color(s)');

writeln;

until p2=p; { loop until number of good guess = number of pegs }

writeln('You have broken the code in ',guess-1,' guesses');

readln;

End.

It should work fine if you need more help let me know.

uses crt;

type

pegstype = array[1..10] of integer;

var

user,pegs,pegs2 : pegstype;

guess,x,p,c,p2,c5 : integer;

{ --------------------------

procedure Correct(p,c : integer; user,pegs : pegstype; var c5,p2 :

integer); { cheks if done or not }

var p3,b,c2,c3,c4 : integer;

colsc, { code colors }

colsg { colors from user }

: array[1..9] of integer;

begin

b := 0;

{ counts correct pegs }

for c2 := 1 to p do if (user[c2]=pegs[c2]) then b := b+1;

p2 := b;

{ counts correct colors }

pegs2 := pegs;

p3 := p;

{ fills COLSc with the colors in PEGS }

c4 := 0;

for c2 := 1 to c do

begin

if (pegs[c2])=c2 then

begin

c4 := c4+1;

colsc[c4] := c2;

end;

end;

{ fills COLSg with the colors in USER }

b := 0;

for c2 := 1 to c do

begin

if (user[c2]=c2) then

begin

b := b+1;

colsg[b] :=c2;

end;

end;

{ finally counts the correct colors }

c5 := 0; { says how many colors correct }

for c2 := 1 to c4 do

for c3 := 1 to b do

if colsg[c3]=colsc[c2] then c5 := c5+1;

end;

{===

==========================

Begin

clrscr;

randomize;

{ ask user how many pegs and colors to use }

write('How many pegs (1-10) -->');

readln(p);

write('How many colors (1-9) -->');

readln(c);

{ initializes the pegs }

for x := 1 to p do pegs[x] := random(c)+1;

{ starts playing the game }

guess := 1;

repeat

writeln('Guess ',guess);

for x := 1 to p do

begin

write('Peg ',x,' -->');

readln(user[x]);

end;

guess := guess+1;

correct(p,c,user,pegs,c5,p

writeln('You have ',p2,' correct peg(s)');

writeln('and ',c5,' correct color(s)');

writeln;

until p2=p; { loop until number of good guess = number of pegs }

writeln('You have broken the code in ',guess-1,' guesses');

readln;

End.

It should work fine if you need more help let me know.