4 ms·
For the N-queens problem, especially as N grows large, there is an interesting probabilistic solution that generally is (absurdly) fast. Put the N queens rando
by TheLoneWolfling 12y ago
For the N-queens problem, especially as N grows large, there is an interesting probabilistic solution that generally is (absurdly) fast.
Put the N queens randomly on the board. Then repeatedly pick the queen that is attacked by the most other queens (if/when there are multiple, pick randomly), and place it in the spot where it is attacked by the least other queens (if/when there are multiple, pick randomly). Repeat until you have a solution.
- taeric 12y agoIf you are just looking for a solution, DLX is already absurdly fast. Granted, as N grows exceptionally large, it may be that it is also absurdly memory hungry. :) Also note, that it isn't even the best algorithm around. Just pretty good.