doasku

Sudoku solver
git clone git://git.dimitrijedobrota.com/doasku.git
Log | Files | Refs

grid.hpp (955B)


      1 #ifndef DOASKU_GRID_HPP
      2 #define DOASKU_GRID_HPP
      3 
      4 #include <string>
      5 #include <utility>
      6 
      7 #include "cord.hpp"
      8 #include "ref.hpp"
      9 
     10 class Grid {
     11   public:
     12     Grid(const std::string &s);
     13 
     14     bool solve();
     15     void print() const;
     16 
     17   private:
     18     using operation_t = std::tuple<acord_t, uint16_t>;
     19 
     20     void op_set(operation_t op);
     21     void op_mask(operation_t op);
     22     void op_clear(operation_t op);
     23 
     24     void op_clear_row(operation_t op);
     25     void op_clear_col(operation_t op);
     26 
     27     void op_clear_row_rel(operation_t op);
     28     void op_clear_col_rel(operation_t op);
     29 
     30     void _set(acord_t ab, uint8_t value);
     31     void _mask(acord_t ab, uint16_t mask);
     32     void _clear(acord_t ab, uint8_t value);
     33 
     34     void _clear_row(cord_t sg, uint8_t row, uint8_t value);
     35     void _clear_col(cord_t sg, uint8_t col, uint8_t value);
     36 
     37     bool _is_finished(uint8_t subgrid);
     38     bool _is_finished();
     39 
     40     Ref subgrids[9], rows[9], cols[9];
     41     bool changed = false;
     42 };
     43 
     44 #endif