int main() { const char *puz = "...5...8......1..2..5.9...4.6..34..9.38...26.2..61..5.9...2.3..6..8......4...5..."; struct dlx solver; dlx_solver_init(&solver); dlx_solve(&solver, puz); dlx_solve(&solver, puz); return 0; }
void worker() { int nchars = 0; int retval; char input_path[512]; char output_path[512]; FILE* outfile; FILE *infile; boinc_resolve_filename(INPUT_FILE, input_path, sizeof(input_path)); #ifdef _WIN32 infile = boinc_fopen(input_path, "rb"); #else infile = boinc_fopen(input_path, "r"); #endif if (!infile) { fprintf(stderr, "Couldn't find input file, resolved name %s.\n", input_path ); exit(-1); } // Dance Dance Revolution dfio_load_file(infile); SBMatrix* matrix = new SBMatrix(); retval = dfio_read_matrix(matrix); if (retval) { fprintf(stderr, "APP: bdance parse input file failed:\n"); fprintf(stderr, "error code %d\n", retval); dfio_cleanup(); exit(1); } dfio_cleanup(); fclose(infile); // Solve dlx_solve(matrix); uxlong solutions = dlx_count_solutions(); delete matrix; // Write results. boinc_resolve_filename(OUTPUT_FILE, output_path, sizeof(output_path)); outfile = boinc_fopen(output_path, "w"); if (!outfile) { fprintf(stderr, "Couldn't find output file, resolved name %s.\n", output_path ); exit(-1); } dfio_new_file(outfile, DFIO_TYPE_RESULT); // if (dfio_get_prop(DFIO_PROP_NO_SOLUTION_DATA)) { dfio_set_prop(DFIO_PROP_RESULTS_NUM, solutions); dfio_write_headers(); // } dfio_cleanup(); fclose(outfile); boinc_finish(0); }