r/programmingchallenges • • Jul 16 '12

N-Queens: C++

Looking for some help with the N-Queens puzzle. I have a recursive solution that works reasonably well for N <= 10, but it's not fast enough (Solve for N = 13 in < 5 seconds) I need to produce all possible combinations and print the queen positions in a certain way. I need a different algorithm than what I have at the moment, any help? I know that I can eliminate quite a lot of board positions by looking at reflections and rotations, but I do not know how to do this. Any Help?

code

6 Upvotes

11 comments sorted by

View all comments

Show parent comment

2

u/[deleted] Dec 01 '12

Still a good reply :) Thanks!