I have difficulties in a problem, which at first I thought was very trivial, but in the end I did not manage to do it. It is an exercise of an Algorithm test that is below:

MASTERMIND GAME

CONSIDER THE FOLLOWING DEFINITIONS:

const MAX = 20; CORINI = 1; CORFIM = 30;

Types of colors: CORINI..CORFIM; (*range of values, subtype of integer*)

vector = matrix [1..MAX] of colors;

1. Present, in Pascal, procedures or functions for:

(a) Read a vector with n ∈ ∈.[2..MAX] elements of the type colors, ensuring that all the elements belong to the interval[CORINI,CORFIM] and that there is no element repeated in the read vector;

In the paschal language, the program in the paschal language, but I have the following error:

I do not know how, accept any value of the user, integrate let's say, and assign it in a variable of type of color.

My code is below:

`program mastermind;`

const MAX = 20; CORINI = 1; CORFIM = 30;

Types of colors = CORINI..CORFIM; (*range of values, subtype of integer*)

vector = matrix [1..MAX] of colors;

var vector_of_cores: vector; n: integer;

(s): Boolean;

start

this_no_interval: = False;

if (n> = 1) and (n <= 30) then

this_no_interval: = True;

finish;

(in the event of an error).

var i: integer;

start

eh_repetido: = True;

if limiter = 1 then

eh_repetido: = False

other

start

for i: = 1 to limiter-1 of.

start

yes vector_of_cores[i] = x then

eh_repetido: = False;

finish;

finish;

finish;

(in the event of an error).

start

(this_no_interval (x) = False) or (eh_repetido (vector_of_cores, i, x) = True)

start

writeln (& # 39; invalid entry & # 39;);

read (x);

valid_value: = x;

finish;

finish;

(in the event of an error).

var i: integer; x: integer;

start

for i: = 1 to n

start

read (x);

vector_of_cores: = valid_value (x, vector_of_cores, i);

```
finish;
```

finish;

(*MAIN PROGRAM*)

start

read (n); (*n is a vector tam between 2 and MAX*)

ler_vetor (n vetor_de_cores);

final.