doaskuHuman-like solver for sudoku |
git clone git://git.dimitrijedobrota.com/doasku.git |
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING |
grid.hpp (962B)
0 #ifndef DOASKU_GRID_HPP
1 #define DOASKU_GRID_HPP
3 #include <array>
4 #include <string>
5 #include <utility>
7 #include "cord.hpp"
8 #include "ref.hpp"
10 class grid
11 {
12 public:
13 explicit grid(const std::string& str);
15 bool solve();
16 void print() const;
18 private:
19 using operation_t = std::tuple<acord_t, uint16_t>;
21 void op_set(operation_t opr);
22 void op_mask(operation_t opr);
23 void op_clear(operation_t opr);
25 void op_clear_row(operation_t opr);
26 void op_clear_col(operation_t opr);
28 void op_clear_row_rel(operation_t opr);
29 void op_clear_col_rel(operation_t opr);
31 void set(acord_t abs, uint8_t value);
32 void mask(acord_t abs, uint16_t mask);
33 void clear(acord_t abs, uint8_t value);
35 void clear_row(cord_t sbgrd, uint8_t row, uint8_t value);
36 void clear_col(cord_t sbgrd, uint8_t col, uint8_t value);
38 bool is_finished(uint8_t subgrid);
39 bool is_finished();
41 std::array<ref, 9> m_subgrids, m_rows, m_cols;
42 bool m_changed = false;
43 };
45 #endif