Quote Originally Posted by yawbird
Hi there!!
sorry for gettin back to you so late... had a pile of stuff due in
Right Iv had a little bash at writing those 2 procedures. They dont seem to compile properly
as i dont seem to grasp them that well...yet


type TColours = (Blue, Red, Green, Black);
var A: array[0..3] of TColours;
B: array[0..11] of TColours;


procedure SetColour;
{will this randomly set the elements to different different colours or just set a whole array to a random colour. Also am i using the logic notation correctly?}
begin
repeat
randomize;
random(A);
random(B);

until
B = not(black) and A = not(black);

end;
[pascal]

type TColours = (Blue, Red, Green, Black);
var A: array[0..3] of TColours;
B: array[0..11] of TColours;

procedure SetColour;
{ This sets all the elements of A and B to a random value, except black }
var
i: Integer;
begin
for i := 0 to 3 do // Iterate though elements of array A
A[i] := TColours(Random(3)); // Returns random integer from 0..2 (black is 3, so is excluded)

for i := 0 to 11 do
B[i] := TColours(Random(3));
end;
[/pascal]

Note, you should only call Randomize once, at the beginning of your application.

procedure RemovePairs(var C: array of TColours);
{am i declarin the param correctly? basically i wish to write removepairs(X) where X is the array to be checked}
var i : integer;
begin

for i = 1 to high(C) do
begin
if C[i] = C[i-1] then
C[i-1] := black
if not C[i] = C[i+1] then
C[i] := black
end;
end;

{Does high return the last element of the array? and secondly does this make any sense? im trying to get it to go through each element and if 2 next to each other are the same colour then they both turn black}
That looks okay...