Is it good enough?

One day, my friend asked me if I still remember the solution of eight queens puzzle.
I told him the answer is no.
In effect, I had never worked on the problem before.
After that chat, I decide to do the math via my new joy Golang.

here is my code:

My solution of “Eight Queens Puzzle”

In the code above , I print the solution on screen, but it is not necessary, you can remove the function visualize then just counting.

In my old ThinkPad E431,
running 8 queens costs less than 1ms. (without print)

running 9 queens costs less than 2ms. (without print)

running 10 queens costs less than 9ms. (without print)

So… is it good enough?


Maybe use a struct for the x,y coords and a type for the slice of coords. Like this:

better to read, thanks.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.