Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

5: attempt to perform arithmetic on field '?' (a nil value)?

Asked by 5 years ago
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)

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

Answer this question