grid.hpp (962B)
1 #ifndef DOASKU_GRID_HPP 2 #define DOASKU_GRID_HPP 3 4 #include <array> 5 #include <string> 6 #include <utility> 7 8 #include "cord.hpp" 9 #include "ref.hpp" 10 11 class grid 12 { 13 public: 14 explicit grid(const std::string& str); 15 16 bool solve(); 17 void print() const; 18 19 private: 20 using operation_t = std::tuple<acord_t, uint16_t>; 21 22 void op_set(operation_t opr); 23 void op_mask(operation_t opr); 24 void op_clear(operation_t opr); 25 26 void op_clear_row(operation_t opr); 27 void op_clear_col(operation_t opr); 28 29 void op_clear_row_rel(operation_t opr); 30 void op_clear_col_rel(operation_t opr); 31 32 void set(acord_t abs, uint8_t value); 33 void mask(acord_t abs, uint16_t mask); 34 void clear(acord_t abs, uint8_t value); 35 36 void clear_row(cord_t sbgrd, uint8_t row, uint8_t value); 37 void clear_col(cord_t sbgrd, uint8_t col, uint8_t value); 38 39 bool is_finished(uint8_t subgrid); 40 bool is_finished(); 41 42 std::array<ref, 9> m_subgrids, m_rows, m_cols; 43 bool m_changed = false; 44 }; 45 46 #endif