N = 8 --board size
--make sure place (n,c) is away from attacks
function isplaceok (a, n, c)
if (a[i] == c) or
(a[i] - i == c - n) or
(a[i] + i == c + n) then
return false
end
return true
end
function printsolution (a)
for i = 1, N do
for j = 1, N do
io.write(a[i] == j and "x" or "_", " ")
end
io.write("\n")
end
io.write("\n")
end
function addqueen (a,n)
if n > N then
printsolution(a)
else
for c = 1, N do
if isplaceok(a, n, c) then
a[n] = c
addqueen (a, n + 1)
end
end
end
end
addqueen({}, 1)
COMMUNITY QUESTION
5: attempt to perform arithmetic on field '?' (a nil value)?
0 answers
No public answers were preserved for this question.
This discussion is preserved as it was. New answers, comments, and votes are closed.

7 comments
LOL, just gonna delete your last question after i answer it.
No. You didn't.
You helped me on the end but not this one.
Yes, but after i answered your last question, you edited it to ask a different question and asked for more help.
then i said ask another question then, so you deleted the other one.
w/e, just saying, bad manners.
yes I asked this on. I assumed you meant to delete it then make a new one. Was I wrong?