Hello!!

I have one problem.

I most write program in prolog.

This problem is:

I have 6 military units and 6 soldier ( each have different status).

I most make a one formation, matrix, 6*6, which most

be, that in each row and each coloumn are one soldier from each status

and one soldier from each units.

I really need this. Please..

I have and 1 programs, which do not works and they needs be fixed.

If any know results, please send me results.

I will be wery grateful.

The program is:

1.

end:-

write('Rankings from soldier are a,b,c,d,e i f, and military

units are 1,2,3,4,5 i 6.'), nl,

assert(count(1)), asserta(rankings(1, [a,b,c,d])),

asserta(unit(1, [1,2,3,4])),

begin, nl, write('Results is::'), nl, give(1,1),

retractall(rankings(X,Y)),

retractall(unit(X1,Y1)), retractall(count(N)),

retractall(warn(U,I,O,P)).

begin:- make_rankings, unit(1,N), mix(N,L), delete, assert(unit(1,L)),

begin1.

begin.

begin1:- make_unit, unit(1, List), mix(List, New), delete, find(New).

make_rankings:- count(N), rankings(N, List), N1 is N + 1, mix(List,

New),

asserta(rankings(N1,New)), retract(count(N)),

assert(count(N1)), N1<4, make_rankings.

make_rankings:- retractall(count(N)), assert(count(1)).

make_unit:- count(N), unit(N, List), N1 is N + 1, mix(List, New),

asserta(unit(N1,New)), retract(count(N)),

assert(count(N1)), N1<4, make_unit.

make_unit:- retractall(count(N)), assert(count(1)).

delete:- retractall(count(N)), retractall(warn(M,K,L,O)),

assert(count(1)).

mix([Head|Tail], New):- unite(Tail, [Head], New).

unite([], X, X).

unite([X|Xr],Y,[X|Z]):-unite(Xr,Y,Z).

mix([],[]).

mix(L,[X|Xr]:- choose(X,L,Ost), mix(Ost,Xr).

choose(X,[X|Xr],Xr).

choose(X,[Y|Yr],[Y|Z]):- choose(X,Yr,Z).

find([Head|Tail]):- count(N), rankings(N, rankingsovi), unit(Head,

unit), !, insert(rankingsovi, unitinice, N, 1),

!, retract(count(N)), N1 is N + 1, assert(count(N1)),

find(Tail).

find([]).

insert([Grankings|Rrankings],[Gunit|Runit], Row, Coloumn):- not

warn(X,V, Grankings,Gunit), %not warn(W, Coloumn, U, Gunit),

assert(warn(Row, Coloumn, Grankings,Gunit)), Coloumn1 is

Coloumn + 1, insert(Rrankings, Runit, Row, Coloumn1).

insert([],[], Row, Coloumn).

give(Row, Coloumn):- Coloumn=<4, warn(Row, Coloumn, rankings, unit),

write(rankings), write(unit), tab(3),

Coloumn1 is Coloumn + 1, give(Row, Coloumn1).

give(Row, Coloumn):- nl, Row<4, Row1 is Row + 1, give(Row1, 1).

give(Row, Coloumn).