james donald

9 Reputation

2 Badges

12 years, 162 days

MaplePrimes Activity


These are questions asked by james donald

my programme seems to be giving me all permutations on a nXn board been trying to find where i went wrong but its took me days and still cant locate ... i want this procedure to give me the n queens on a nxn board that are non attacking. please help

.place:=proc(z)
global L;
local i,k;
k:=z;
L:= Array(1..k);
for i from 1 to k do
if L(i)=L(k) # two in the same column
or abs(L(i)-L(k)) = abs(i-k) # in the same diagonal
then
return (false);
fi:
od:
return (true);
end proc:

Page 1 of 1