-
Notifications
You must be signed in to change notification settings - Fork 0
/
bits.h
64 lines (47 loc) · 1.51 KB
/
bits.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*---------------------------------------------------------------------------*
* "Bits" represents a Sudoku board state, where each cell has:
* - A value: 1-9 indicate a filled-in number, 0 indicates unknown
* - A bitmask: 9 bits, indicating whether each number 1-9 is a possible candidate (1), or whether it is disallowed (0)
*----------------------------------------------------------------------------*/
#ifndef BITS_H
#define BITS_H
#include <iostream>
#include <vector>
#include "coords.h"
#include "bitmatrix.h"
class Bits : public BitMatrix {
public:
Bits();
~Bits();
Bits(const Bits& bitss);
Bits& operator=(const Bits& bitss);
void init();
void set_value(Spot p, int val);
bool has_value(Spot p);
int get_value(Spot p);
void remove_candidate(Spot p, int val);
bool has_candidate(Spot p, int val);
int get_candidate_int(Spot p, int val);
int count_candidates(Spot p);
int first_bit(Spot p);
int bit_of_spot(Spot p);
int bit_of_spots(std::vector<Spot>& pl);
int open_bit_of_row(int row);
int open_bit_of_col(int col);
int open_bit_of_box(int boxid);
std::vector<Spot> covers_of_spot(Spot p, int val);
bool is_possible(Spot p);
void not_possible(Spot p);
bool complete();
bool valid_now();
bool solved();
int* numbers;
int* bits;
int* possibles;
};
int count_bits(int bit);
int first_bits(int bit);
std::ostream& operator << (std::ostream& os, Bits& bits);
std::istream& operator >> (std::istream& os, Bits& bits);
std::ostream& operator <<= (std::ostream& os, Bits& bits);
#endif