|
From: Foster B. <fos...@us...> - 2006-02-03 18:20:57
|
Update of /cvsroot/adobe-source/adobe-source/adobe/test/n_queens In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1031/adobe/test/n_queens Modified Files: main.cpp Log Message: asl 1.0.13 Index: main.cpp =================================================================== RCS file: /cvsroot/adobe-source/adobe-source/adobe/test/n_queens/main.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** main.cpp 6 Jan 2006 18:35:26 -0000 1.2 --- main.cpp 3 Feb 2006 18:20:49 -0000 1.3 *************** *** 1,6 **** /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ --- 1,6 ---- /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ *************** *** 23,73 **** std::size_t dancing_queens() { ! enum ! { ! diag_count = N * 2 - 1, ! max_d_index = 2 * N - 2, ! cols_k = N * 2 + diag_count * 2, ! rows_k = N * N, ! file_base = N, ! diagonals_base = file_base + N, ! rdiagonals_base = diagonals_base + diag_count ! }; ! adobe::dancing_links<rows_k, cols_k> links; ! std::size_t row_index(0); ! // std::cerr << "total rows: " << rows_k << ", cols: " << cols_k << std::endl; ! for (std::size_t i(0); i < N; ++i) ! { ! for (std::size_t j(0); j < N; ++j) ! { ! std::size_t R(i); ! std::size_t F(j); ! std::size_t A(i + j); ! std::size_t B(N - 1 - i + j); #if 0 ! std::cerr << row_index << ") " ! << " R" << R << "(" << R << ")" ! << " F" << F << "(" << F + file_base << ")" ! << " A" << A << "(" << A + diagonals_base << ")" ! << " B" << B << "(" << B + rdiagonals_base << ")" ! << std::endl; #endif ! links.set(row_index, R); ! links.set(row_index, F + file_base); ! links.set(row_index, A + diagonals_base); ! links.set(row_index, B + rdiagonals_base); ! links.set_secondary_column(A + diagonals_base); ! links.set_secondary_column(B + rdiagonals_base); ! ++row_index; ! } ! } ! return links.search(std::numeric_limits<std::size_t>::max()); } --- 23,73 ---- std::size_t dancing_queens() { ! enum ! { ! diag_count = N * 2 - 1, ! max_d_index = 2 * N - 2, ! cols_k = N * 2 + diag_count * 2, ! rows_k = N * N, ! file_base = N, ! diagonals_base = file_base + N, ! rdiagonals_base = diagonals_base + diag_count ! }; ! adobe::dancing_links<rows_k, cols_k> links; ! std::size_t row_index(0); ! // std::cerr << "total rows: " << rows_k << ", cols: " << cols_k << std::endl; ! for (std::size_t i(0); i < N; ++i) ! { ! for (std::size_t j(0); j < N; ++j) ! { ! std::size_t R(i); ! std::size_t F(j); ! std::size_t A(i + j); ! std::size_t B(N - 1 - i + j); #if 0 ! std::cerr << row_index << ") " ! << " R" << R << "(" << R << ")" ! << " F" << F << "(" << F + file_base << ")" ! << " A" << A << "(" << A + diagonals_base << ")" ! << " B" << B << "(" << B + rdiagonals_base << ")" ! << std::endl; #endif ! links.set(row_index, R); ! links.set(row_index, F + file_base); ! links.set(row_index, A + diagonals_base); ! links.set(row_index, B + rdiagonals_base); ! links.set_secondary_column(A + diagonals_base); ! links.set_secondary_column(B + rdiagonals_base); ! ++row_index; ! } ! } ! return links.search(std::numeric_limits<std::size_t>::max()); } *************** *** 77,89 **** void dancing_queen_iteration() { ! adobe::timer_t timer; ! std::size_t solutions(dancing_queens<N>()); ! double time(timer.split()); ! std::cout << "Found " << solutions << " solutions to the " ! << N << "-queens problem in " << time << " miliseconds (" ! << (time / 1e3) << " seconds )" << std::endl; ! dancing_queen_iteration<N+1>(); } --- 77,89 ---- void dancing_queen_iteration() { ! adobe::timer_t timer; ! std::size_t solutions(dancing_queens<N>()); ! double time(timer.split()); ! std::cout << "Found " << solutions << " solutions to the " ! << N << "-queens problem in " << time << " miliseconds (" ! << (time / 1e3) << " seconds )" << std::endl; ! dancing_queen_iteration<N+1>(); } *************** *** 93,103 **** void dancing_queen_iteration<18>() { ! adobe::timer_t timer; ! std::size_t solutions(dancing_queens<18>()); ! double time(timer.split()); ! std::cout << "Found " << solutions << " solutions to the " ! << 18 << "-queens problem in " << time << " miliseconds (" ! << (time / 1e3) << " seconds )" << std::endl; } --- 93,103 ---- void dancing_queen_iteration<18>() { ! adobe::timer_t timer; ! std::size_t solutions(dancing_queens<18>()); ! double time(timer.split()); ! std::cout << "Found " << solutions << " solutions to the " ! << 18 << "-queens problem in " << time << " miliseconds (" ! << (time / 1e3) << " seconds )" << std::endl; } *************** *** 110,115 **** int main(int argc, char** argv) { ! dancing_queen_iteration<1>(); ! return 0; } --- 110,115 ---- int main(int argc, char** argv) { ! dancing_queen_iteration<1>(); ! return 0; } |