# Question:I don't know What's the problem ???

## Question:I don't know What's the problem ???

Maple

Hi all,

The following is my 'poor' attempt at coding the n by n queen problem. I am an amature programmer. The codes individually seem to work fine but when i put it all together it dose not seem to work and it does not produce an error so i don't know where its going wrong.

I would really really appriciate greatly if someone can help me please.

with(combinat):
with(linalg):
with(ArrayTools):
with(MTM):
Queens:=proc(n)
local INPU,RownColumn,Diagn, y, u,q,Y,Y1:
INPU:=proc(n,q)
local m,p,i:

m:=Matrix(n):
p:=q:
for i from 1 to n do
m(p[i],i):=1:
od:
return(m)
end proc:

RownColumn:=proc(n)                  #
local m, en, q, w,r,s, Arr:
m:=n:
en:=min(op(1,m)):
Arr:=Array(1..en,fill = 1):

r:=convert(q,Array);
s:=convert(w,Array);

if IsEqual(r,Arr) and IsEqual(s,Arr) then

print(yes):
else
return(NO)
fi:
end proc:

Diagn:=proc(n)                           #
local m,en,j,t,m1,k,s,q,w:
m:=n:
en:=min(op(1,m))-1:
for j from -(en) to en do
q:=diag(m,j);
if t > 1  then
return(No)
fi:
od;
m1:=FlipDimension(m,2);
for k from -(en) to en do
w:=diag(m1,k);
if s > 1 then
return(No)
fi:
od;
return(yes)
end proc:

permute(n):
u := %:

for y from 1 to nops(u) do
q:=op(y,u);
INPU(n,q):
Y:=RownColumn(INPU(n,q)):
Y1:=Diagn(INPU(n,q)):

if Y = yes and Y1 = yes then
print(q);
fi:
od;
end proc:
Queens(4);
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes
yes

﻿