| 295 | unsigned first_potential_set); |
| 296 | |
| 297 | void partial_solve(stdexec::parallel_scheduler sch, |
| 298 | stdexec::simple_counting_scope &scope, |
| 299 | stdexec::inplace_stop_source &stop, |
| 300 | std::unique_ptr<board_element[]> board, |
| 301 | unsigned first_potential_set) |
| 302 | { |
| 303 | if (stop.stop_requested()) |
| 304 | { |
| 305 | ++nRaces; |
| 306 | return; |
| 307 | } |
| 308 | if (fixed_board(board.get())) |
| 309 | { |
| 310 | if (++nSols == 1 && verbose) |
| 311 | { |
| 312 | print_board(board.get()); |
| 313 | } |
| 314 | if (find_one) |
| 315 | { |
| 316 | stop.request_stop(); |
| 317 | } |
| 318 | return; |
| 319 | } |
| 320 | calculate_potentials(board.get()); |
| 321 | bool progress = true; |
| 322 | bool success = examine_potentials(board.get(), &progress); |
| 323 | if (success && progress) |
| 324 | { |
| 325 | partial_solve(sch, scope, stop, std::move(board), first_potential_set); |
| 326 | return; |
| 327 | } |
| 328 | else if (success && !progress) |
| 329 | { |
| 330 | while (board.get()[first_potential_set].solved_element != 0) |
| 331 | { |
| 332 | ++first_potential_set; |
| 333 | } |
| 334 | auto potential_board = |
| 335 | [=, &scope, &stop, board = std::move(board)](unsigned short potential) mutable noexcept |
| 336 | { |
| 337 | if (1 << (potential - 1) & board.get()[first_potential_set].potential_set) |
| 338 | { |
| 339 | // NOLINTNEXTLINE(bugprone-unhandled-exception-at-new) |
| 340 | std::unique_ptr<board_element[]> new_board(new board_element[BOARD_SIZE]); |
| 341 | copy_board(board.get(), new_board.get()); |
| 342 | new_board.get()[first_potential_set].solved_element = potential; |
| 343 | spawn_partial_solve(sch, scope, stop, std::move(new_board), first_potential_set); |
| 344 | } |
| 345 | }; |
| 346 | for (int i = 1; i < 10; ++i) |
| 347 | { |
| 348 | potential_board(i); |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | void spawn_partial_solve(stdexec::parallel_scheduler sch, |
| 354 | stdexec::simple_counting_scope &scope, |
no test coverage detected