A solution to the Eight Queens problem in 10 lines C++. The program prints all the 92 solutions in the form of column indices.
eight_queens_in_10_lines.cc
is the 10-line versioneight_queens.cc
is the same alorithm of normal stylen_queens.cc
is the generalized version
Passed on GCC (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0, -std=c++11 flag is required.
The purpose of this code is to minimize the lines, therefore, the code will be tricky and hard to read. Also, its performance will not be satisfying. The profiler shows that the sort() part takes most of the time.