Skip to content

Commit

Permalink
Add more debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
dark committed Feb 3, 2024
1 parent 97833f2 commit 5c20bea
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions create_random.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,18 @@ std::optional<Board> create_random_board(const uint16_t board_size, std::mt19937
// restore the leftover trackers.
const int current_value = b.at(state.row, state.column);
if (current_value != 0) {
rows[state.row].insert(current_value);
columns[state.column].insert(current_value);
auto [r_i, r_inserted] = rows[state.row].insert(current_value);
if (!r_inserted) {
std::cerr << "FATAL: failed to insert value " << current_value << " into row "
<< state.row << ". This should never happen." << std::endl;
return std::nullopt;
}
auto [c_i, c_inserted] = columns[state.column].insert(current_value);
if (!c_inserted) {
std::cerr << "FATAL: failed to insert value " << current_value << " into column "
<< state.column << ". This should never happen." << std::endl;
return std::nullopt;
}
}

// Take and use the next legal value for the current cell.
Expand Down

0 comments on commit 5c20bea

Please sign in to comment.