|
@@ -575,12 +575,17 @@ impl AnyPossible {
|
|
}
|
|
}
|
|
|
|
|
|
#[must_use]
|
|
#[must_use]
|
|
|
|
+ /// find pairs (same possible number in different cell locations)
|
|
|
|
+ /// This finds them all, and is not limited to finding 2.
|
|
|
|
+ /// Returns
|
|
|
|
+ /// - Vector of (Vec(positions), Vec(values))
|
|
|
|
+ /// - If possible was modified, return true
|
|
pub fn find_pairs(&mut self, cellgroup: &[usize]) -> (Vec<(Vec<usize>, Vec<u8>)>, bool) {
|
|
pub fn find_pairs(&mut self, cellgroup: &[usize]) -> (Vec<(Vec<usize>, Vec<u8>)>, bool) {
|
|
// result[value] = indexes where it is located?
|
|
// result[value] = indexes where it is located?
|
|
// Step 1: find values, and their position(s).
|
|
// Step 1: find values, and their position(s).
|
|
|
|
|
|
let initial = GenBits::new(self.width as usize);
|
|
let initial = GenBits::new(self.width as usize);
|
|
- let mut result: Vec<GenBits> = vec![initial; self.width as usize];
|
|
|
|
|
|
+ let mut value_positions: Vec<GenBits> = vec![initial; self.width as usize];
|
|
|
|
|
|
// let cellgroup = self.group.group(Groups::Cell, cell_index);
|
|
// let cellgroup = self.group.group(Groups::Cell, cell_index);
|
|
|
|
|
|
@@ -588,44 +593,39 @@ impl AnyPossible {
|
|
for pos in 0..self.width {
|
|
for pos in 0..self.width {
|
|
let cellindex = cellgroup[pos as usize];
|
|
let cellindex = cellgroup[pos as usize];
|
|
|
|
|
|
- if self.get(cellindex, value as usize + 1)
|
|
|
|
- // .get(self.possible.pos(x, y), value as usize + 1)
|
|
|
|
- {
|
|
|
|
|
|
+ if self.get(cellindex, value as usize + 1) {
|
|
// println!("Found {} ({},{}) = {}", cell_index, x, y, value);
|
|
// println!("Found {} ({},{}) = {}", cell_index, x, y, value);
|
|
- result[value as usize].set(pos as usize, true);
|
|
|
|
|
|
+ value_positions[value as usize].set(pos as usize, true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Step 2: pair them up, and if complete, fixup possible (if needed).
|
|
// Step 2: pair them up, and if complete, fixup possible (if needed).
|
|
|
|
|
|
- let zero_bits = GenBits::new(self.width as usize);
|
|
|
|
let width = self.width;
|
|
let width = self.width;
|
|
let mut possibles_updated: bool = false;
|
|
let mut possibles_updated: bool = false;
|
|
let mut pairs: Vec<(Vec<usize>, Vec<u8>)> = vec![];
|
|
let mut pairs: Vec<(Vec<usize>, Vec<u8>)> = vec![];
|
|
|
|
|
|
'outer: for idx in 0..width - 1 {
|
|
'outer: for idx in 0..width - 1 {
|
|
// pos_found contains the positions.
|
|
// pos_found contains the positions.
|
|
- let pos_found = &result[idx as usize];
|
|
|
|
|
|
+ let pos_found = &value_positions[idx as usize];
|
|
if pos_found.count_set() == 0 {
|
|
if pos_found.count_set() == 0 {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
if idx > 0 {
|
|
if idx > 0 {
|
|
// Check previous for matches - already checked...
|
|
// Check previous for matches - already checked...
|
|
for check in 0..idx {
|
|
for check in 0..idx {
|
|
- if *pos_found == result[check as usize] {
|
|
|
|
|
|
+ if *pos_found == value_positions[check as usize] {
|
|
continue 'outer;
|
|
continue 'outer;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
let count = pos_found.count_set();
|
|
let count = pos_found.count_set();
|
|
- /*
|
|
|
|
if count == 1 {
|
|
if count == 1 {
|
|
// Single possible item here ... skip this for now.
|
|
// Single possible item here ... skip this for now.
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- */
|
|
|
|
|
|
|
|
let mut matches = 1;
|
|
let mut matches = 1;
|
|
// Pos contains the numbers in the cell.
|
|
// Pos contains the numbers in the cell.
|
|
@@ -634,7 +634,7 @@ impl AnyPossible {
|
|
|
|
|
|
if count != 1 {
|
|
if count != 1 {
|
|
for look in idx + 1..width {
|
|
for look in idx + 1..width {
|
|
- if result[look as usize] == *pos_found {
|
|
|
|
|
|
+ if value_positions[look as usize] == *pos_found {
|
|
matches += 1;
|
|
matches += 1;
|
|
pos.push(look);
|
|
pos.push(look);
|
|
}
|
|
}
|
|
@@ -644,13 +644,13 @@ impl AnyPossible {
|
|
if matches == count {
|
|
if matches == count {
|
|
// Ok! We found a pair (or triple, or quad, or ...)
|
|
// Ok! We found a pair (or triple, or quad, or ...)
|
|
// Build new possible
|
|
// Build new possible
|
|
- let mut new_possible = zero_bits.clone();
|
|
|
|
|
|
+ let mut new_possible = GenBits::new(width as usize);
|
|
for p in &pos {
|
|
for p in &pos {
|
|
new_possible.set(*p as usize, true);
|
|
new_possible.set(*p as usize, true);
|
|
}
|
|
}
|
|
let mut index_pos = Vec::<usize>::new();
|
|
let mut index_pos = Vec::<usize>::new();
|
|
|
|
|
|
- for p in pos_found.indexes() {
|
|
|
|
|
|
+ for p in pos_found.iter() {
|
|
index_pos.push(p);
|
|
index_pos.push(p);
|
|
if self.possible[cellgroup[p as usize]] != new_possible {
|
|
if self.possible[cellgroup[p as usize]] != new_possible {
|
|
// println!("Update pos {} with {:?}", p, new_possible);
|
|
// println!("Update pos {} with {:?}", p, new_possible);
|
|
@@ -675,30 +675,21 @@ impl AnyPossible {
|
|
|
|
|
|
#[must_use]
|
|
#[must_use]
|
|
/// Find positions where each value is possible.
|
|
/// Find positions where each value is possible.
|
|
- /// - Vec index is value
|
|
|
|
- /// - GenBits are the positions it is found.
|
|
|
|
|
|
+ /// - Vec index is the value - 1 !
|
|
|
|
+ /// - GenBits are the positions found.
|
|
pub fn find_value_pos(&self) -> Vec<GenBits> {
|
|
pub fn find_value_pos(&self) -> Vec<GenBits> {
|
|
- let zero = GenBits::new(self.width as usize);
|
|
|
|
- let mut result = vec![zero.clone(); self.width as usize];
|
|
|
|
|
|
+ let zero = GenBits::new(self.max_index as usize);
|
|
|
|
+ let mut result = vec![zero; self.width as usize];
|
|
|
|
|
|
- for index in 0..self.width {
|
|
|
|
- if self.possible[index as usize] == zero {
|
|
|
|
|
|
+ for index in 0..self.max_index {
|
|
|
|
+ if self.possible[index as usize].count_set() == 0 {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
// Ok, there's some value there.
|
|
// Ok, there's some value there.
|
|
- // Would it be better to use the iterator here? Yes, I think so.
|
|
|
|
- for v in self.possible[index as usize].indexes() {
|
|
|
|
|
|
+ for v in self.possible[index as usize].iter() {
|
|
result[v as usize].set(index as usize, true);
|
|
result[v as usize].set(index as usize, true);
|
|
}
|
|
}
|
|
-
|
|
|
|
- /*
|
|
|
|
- for v in 0..self.width {
|
|
|
|
- if self.possible[index as usize].get(v as usize +1) {
|
|
|
|
- result[v as usize].set(index as usize, true);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- */
|
|
|
|
}
|
|
}
|
|
result
|
|
result
|
|
}
|
|
}
|
|
@@ -903,12 +894,14 @@ impl AnySolver {
|
|
// let mut update: bool = false;
|
|
// let mut update: bool = false;
|
|
|
|
|
|
// use width, not size. ;)
|
|
// use width, not size. ;)
|
|
- let mut cell_has_value = vec![false; width as usize];
|
|
|
|
|
|
+ let mut cell_has_value = GenBits::new(self.board.max_index);
|
|
|
|
+ // vec![false; self.board.max_index];
|
|
|
|
|
|
let mut cell_update = vec![false; width as usize];
|
|
let mut cell_update = vec![false; width as usize];
|
|
cell_update[cell_index as usize] = true;
|
|
cell_update[cell_index as usize] = true;
|
|
|
|
|
|
let values = self.possible.find_value_pos();
|
|
let values = self.possible.find_value_pos();
|
|
|
|
+ println!("Values: {:?}", values);
|
|
|
|
|
|
for (value, positions) in values.iter().enumerate() {
|
|
for (value, positions) in values.iter().enumerate() {
|
|
if positions.count_set() == 0 {
|
|
if positions.count_set() == 0 {
|
|
@@ -920,7 +913,7 @@ impl AnySolver {
|
|
cell_has_value.fill(false);
|
|
cell_has_value.fill(false);
|
|
|
|
|
|
for p in positions.iter() {
|
|
for p in positions.iter() {
|
|
- cell_has_value[p as usize] = true;
|
|
|
|
|
|
+ cell_has_value.set(p, true); // [p as usize] = true;
|
|
}
|
|
}
|
|
|
|
|
|
println!("Value {} : Pos {:?}", value, cell_has_value);
|
|
println!("Value {} : Pos {:?}", value, cell_has_value);
|
|
@@ -1969,6 +1962,9 @@ mod tests {
|
|
solver.possible.display();
|
|
solver.possible.display();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Running just this test:
|
|
|
|
+ // cargo test -p sudoku logic_test_pairs -- --ignored --show-output
|
|
|
|
+
|
|
#[ignore]
|
|
#[ignore]
|
|
#[test]
|
|
#[test]
|
|
fn logic_test_pairs() {
|
|
fn logic_test_pairs() {
|
|
@@ -1980,7 +1976,6 @@ mod tests {
|
|
board.set(0, 4, 4);
|
|
board.set(0, 4, 4);
|
|
board.set(1, 7, 5);
|
|
board.set(1, 7, 5);
|
|
board.display();
|
|
board.display();
|
|
- let mut solver = AnySolver::new_from(&board);
|
|
|
|
/*
|
|
/*
|
|
╔═══╦═══╦═══╗
|
|
╔═══╦═══╦═══╗
|
|
║ 2 ║ ║ ║
|
|
║ 2 ║ ║ ║
|
|
@@ -1996,7 +1991,11 @@ mod tests {
|
|
║ ║ ║ ║
|
|
║ ║ ║ ║
|
|
╚═══╩═══╩═══╝
|
|
╚═══╩═══╩═══╝
|
|
P = Possible pair (3,5)
|
|
P = Possible pair (3,5)
|
|
|
|
+ */
|
|
|
|
+ let mut solver = AnySolver::new_from(&board);
|
|
|
|
|
|
|
|
+ solver.possible.display();
|
|
|
|
+ /*
|
|
(1,1):1,6,7,8,9 (2,1): (3,1):1,4,6,7,8,9 (4,1):1,3,4,5,6,7,8,9 (5,1):1,3,4,5,6,7,8,9 (6,1):1,3,4,5,6,7,8,9 (7,1):1,3,4,5,6,7,8,9 (8,1):1,3,4,5,6,7,8,9 (9,1):1,3,4,5,6,7,8,9
|
|
(1,1):1,6,7,8,9 (2,1): (3,1):1,4,6,7,8,9 (4,1):1,3,4,5,6,7,8,9 (5,1):1,3,4,5,6,7,8,9 (6,1):1,3,4,5,6,7,8,9 (7,1):1,3,4,5,6,7,8,9 (8,1):1,3,4,5,6,7,8,9 (9,1):1,3,4,5,6,7,8,9
|
|
(1,2):1,6,7,8,9 (2,2):1,4,6,7,8,9 (3,2): (4,2):1,2,4,5,6,7,8,9 (5,2):1,2,4,5,6,7,8,9 (6,2):1,2,4,5,6,7,8,9 (7,2):1,2,4,5,6,7,8,9 (8,2):1,2,4,5,6,7,8,9 (9,2):1,2,4,5,6,7,8,9
|
|
(1,2):1,6,7,8,9 (2,2):1,4,6,7,8,9 (3,2): (4,2):1,2,4,5,6,7,8,9 (5,2):1,2,4,5,6,7,8,9 (6,2):1,2,4,5,6,7,8,9 (7,2):1,2,4,5,6,7,8,9 (8,2):1,2,4,5,6,7,8,9 (9,2):1,2,4,5,6,7,8,9
|
|
(1,3):1,6,7,8,9 (2,3):1,4,6,7,8,9 (3,3): (4,3):1,2,3,4,6,7,8,9 (5,3):1,2,3,4,6,7,8,9 (6,3):1,2,3,4,6,7,8,9 (7,3):1,2,3,4,6,7,8,9 (8,3):1,2,3,4,6,7,8,9 (9,3):1,2,3,4,6,7,8,9
|
|
(1,3):1,6,7,8,9 (2,3):1,4,6,7,8,9 (3,3): (4,3):1,2,3,4,6,7,8,9 (5,3):1,2,3,4,6,7,8,9 (6,3):1,2,3,4,6,7,8,9 (7,3):1,2,3,4,6,7,8,9 (8,3):1,2,3,4,6,7,8,9 (9,3):1,2,3,4,6,7,8,9
|
|
@@ -2013,9 +2012,31 @@ mod tests {
|
|
|
|
|
|
println!("RIGHT HERE:");
|
|
println!("RIGHT HERE:");
|
|
let g = solver.group.group(Groups::Cell, 3);
|
|
let g = solver.group.group(Groups::Cell, 3);
|
|
- println!("Pairs [cell index 3]: {:?}", solver.possible.find_pairs(g));
|
|
|
|
- solver.finalize_cell(3);
|
|
|
|
|
|
+ let pairs = solver.possible.find_pairs(g);
|
|
|
|
+ println!("Pairs [cell index 3]: {:?}", pairs);
|
|
|
|
+ // Pairs [cell index 3]: ([([0, 6], [2, 4])], true)
|
|
|
|
+
|
|
|
|
+ let expected: Vec<(Vec<usize>, Vec<u8>)> = vec![(vec![0, 6], vec![2, 4])];
|
|
|
|
+ assert_eq!(pairs, (expected, true));
|
|
|
|
+
|
|
|
|
+ // solver.finalize_cell(3);
|
|
solver.possible.display();
|
|
solver.possible.display();
|
|
|
|
+ /*
|
|
|
|
+ (1,1):1,6,7,8,9 (2,1): (3,1):1,4,6,7,8,9 (4,1):1,3,4,5,6,7,8,9 (5,1):1,3,4,5,6,7,8,9 (6,1):1,3,4,5,6,7,8,9 (7,1):1,3,4,5,6,7,8,9 (8,1):1,3,4,5,6,7,8,9 (9,1):1,3,4,5,6,7,8,9
|
|
|
|
+ (1,2):1,6,7,8,9 (2,2):1,4,6,7,8,9 (3,2): (4,2):1,2,4,5,6,7,8,9 (5,2):1,2,4,5,6,7,8,9 (6,2):1,2,4,5,6,7,8,9 (7,2):1,2,4,5,6,7,8,9 (8,2):1,2,4,5,6,7,8,9 (9,2):1,2,4,5,6,7,8,9
|
|
|
|
+ (1,3):1,6,7,8,9 (2,3):1,4,6,7,8,9 (3,3): (4,3):1,2,3,4,6,7,8,9 (5,3):1,2,3,4,6,7,8,9 (6,3):1,2,3,4,6,7,8,9 (7,3):1,2,3,4,6,7,8,9 (8,3):1,2,3,4,6,7,8,9 (9,3):1,2,3,4,6,7,8,9
|
|
|
|
+ (1,4):3,5 (2,4):1,6,7,8,9 (3,4):1,2,6,7,8,9 (4,4):1,2,3,4,5,6,7,8,9 (5,4):1,2,3,4,5,6,7,8,9 (6,4):1,2,3,4,5,6,7,8,9 (7,4):1,2,3,4,5,6,7,8,9 (8,4):1,2,3,4,5,6,7,8,9 (9,4):1,2,3,4,5,6,7,8,9
|
|
|
|
+ (1,5): (2,5):1,6,7,8,9 (3,5):1,2,6,7,8,9 (4,5):1,2,3,5,6,7,8,9 (5,5):1,2,3,5,6,7,8,9 (6,5):1,2,3,5,6,7,8,9 (7,5):1,2,3,5,6,7,8,9 (8,5):1,2,3,5,6,7,8,9 (9,5):1,2,3,5,6,7,8,9
|
|
|
|
+ (1,6):3,5 (2,6):1,6,7,8,9 (3,6):1,2,6,7,8,9 (4,6):1,2,3,4,5,6,7,8,9 (5,6):1,2,3,4,5,6,7,8,9 (6,6):1,2,3,4,5,6,7,8,9 (7,6):1,2,3,4,5,6,7,8,9 (8,6):1,2,3,4,5,6,7,8,9 (9,6):1,2,3,4,5,6,7,8,9
|
|
|
|
+ (1,7):1,2,6,7,8,9 (2,7): (3,7):1,2,4,6,7,8,9 (4,7):1,2,4,5,6,7,8,9 (5,7):1,2,4,5,6,7,8,9 (6,7):1,2,4,5,6,7,8,9 (7,7):1,2,4,5,6,7,8,9 (8,7):1,2,4,5,6,7,8,9 (9,7):1,2,4,5,6,7,8,9
|
|
|
|
+ (1,8):1,2,6,7,8,9 (2,8): (3,8):1,2,4,6,7,8,9 (4,8):1,2,3,4,6,7,8,9 (5,8):1,2,3,4,6,7,8,9 (6,8):1,2,3,4,6,7,8,9 (7,8):1,2,3,4,6,7,8,9 (8,8):1,2,3,4,6,7,8,9 (9,8):1,2,3,4,6,7,8,9
|
|
|
|
+ (1,9):1,2,6,7,8,9 (2,9):1,4,6,7,8,9 (3,9):1,2,4,6,7,8,9 (4,9):1,2,3,4,5,6,7,8,9 (5,9):1,2,3,4,5,6,7,8,9 (6,9):1,2,3,4,5,6,7,8,9 (7,9):1,2,3,4,5,6,7,8,9 (8,9):1,2,3,4,5,6,7,8,9 (9,9):1,2,3,4,5,6,7,8,9
|
|
|
|
+
|
|
|
|
+ ^ This shows that find_pairs is working!
|
|
|
|
+ finalize - should see that 2 is only possible in (1,7), (1,8), and (1,9)
|
|
|
|
+ // OK! find_pairs does work (making the changes) - so I do need to call it, sometime.
|
|
|
|
+ and not in (3,7), (3,8) and (3,9).
|
|
|
|
+ */
|
|
|
|
|
|
/*
|
|
/*
|
|
Pairs: [{1, 4, 8, 6, 7, 0, 5, 2}, {6, 0, 8, 5, 2}, {0, 6}, {}, {0, 6}, {1, 4, 8, 6, 7, 0, 5, 2}, {1, 4, 8, 6, 7, 0, 5, 2}, {1, 4, 8, 6, 7, 0, 5, 2}, {1, 4, 8, 6, 7, 0, 5, 2}]
|
|
Pairs: [{1, 4, 8, 6, 7, 0, 5, 2}, {6, 0, 8, 5, 2}, {0, 6}, {}, {0, 6}, {1, 4, 8, 6, 7, 0, 5, 2}, {1, 4, 8, 6, 7, 0, 5, 2}, {1, 4, 8, 6, 7, 0, 5, 2}, {1, 4, 8, 6, 7, 0, 5, 2}]
|
|
@@ -2024,7 +2045,61 @@ mod tests {
|
|
// Is validate_board destroying our work?!?
|
|
// Is validate_board destroying our work?!?
|
|
// YES IT IS!
|
|
// YES IT IS!
|
|
// assert!(solver.validate_board());
|
|
// assert!(solver.validate_board());
|
|
- solver.possible.display();
|
|
|
|
|
|
+ // solver.possible.display();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #[ignore]
|
|
|
|
+ #[test]
|
|
|
|
+ fn logic_test_triple() {
|
|
|
|
+ let mut board = AnyBoard::new(3);
|
|
|
|
+ board.set(2, 0, 3);
|
|
|
|
+ board.set(2, 1, 4);
|
|
|
|
+ board.set(2, 2, 5);
|
|
|
|
+ board.set(1, 6, 3);
|
|
|
|
+ board.set(1, 7, 4);
|
|
|
|
+ board.set(1, 8, 5);
|
|
|
|
+ // board.display();
|
|
|
|
+ /*
|
|
|
|
+ ╔═══╦═══╦═══╗
|
|
|
|
+ ║ 3║ ║ ║
|
|
|
|
+ ║ 4║ ║ ║
|
|
|
|
+ ║ 5║ ║ ║
|
|
|
|
+ ╠═══╬═══╬═══╣
|
|
|
|
+ ║ ║ ║ ║
|
|
|
|
+ ║ ║ ║ ║
|
|
|
|
+ ║ ║ ║ ║
|
|
|
|
+ ╠═══╬═══╬═══╣
|
|
|
|
+ ║ 3 ║ ║ ║
|
|
|
|
+ ║ 4 ║ ║ ║
|
|
|
|
+ ║ 5 ║ ║ ║
|
|
|
|
+ ╚═══╩═══╩═══╝
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ let mut solver = AnySolver::new_from(&board);
|
|
|
|
+ // solver.possible.display();
|
|
|
|
+ /*
|
|
|
|
+ (1,1):1,2,6,7,8,9 (2,1):1,2,6,7,8,9 (3,1): (4,1):1,2,4,5,6,7,8,9 (5,1):1,2,4,5,6,7,8,9 (6,1):1,2,4,5,6,7,8,9 (7,1):1,2,4,5,6,7,8,9 (8,1):1,2,4,5,6,7,8,9 (9,1):1,2,4,5,6,7,8,9
|
|
|
|
+ (1,2):1,2,6,7,8,9 (2,2):1,2,6,7,8,9 (3,2): (4,2):1,2,3,5,6,7,8,9 (5,2):1,2,3,5,6,7,8,9 (6,2):1,2,3,5,6,7,8,9 (7,2):1,2,3,5,6,7,8,9 (8,2):1,2,3,5,6,7,8,9 (9,2):1,2,3,5,6,7,8,9
|
|
|
|
+ (1,3):1,2,6,7,8,9 (2,3):1,2,6,7,8,9 (3,3): (4,3):1,2,3,4,6,7,8,9 (5,3):1,2,3,4,6,7,8,9 (6,3):1,2,3,4,6,7,8,9 (7,3):1,2,3,4,6,7,8,9 (8,3):1,2,3,4,6,7,8,9 (9,3):1,2,3,4,6,7,8,9
|
|
|
|
+ (1,4):1,2,3,4,5,6,7,8,9 (2,4):1,2,6,7,8,9 (3,4):1,2,6,7,8,9 (4,4):1,2,3,4,5,6,7,8,9 (5,4):1,2,3,4,5,6,7,8,9 (6,4):1,2,3,4,5,6,7,8,9 (7,4):1,2,3,4,5,6,7,8,9 (8,4):1,2,3,4,5,6,7,8,9 (9,4):1,2,3,4,5,6,7,8,9
|
|
|
|
+ (1,5):1,2,3,4,5,6,7,8,9 (2,5):1,2,6,7,8,9 (3,5):1,2,6,7,8,9 (4,5):1,2,3,4,5,6,7,8,9 (5,5):1,2,3,4,5,6,7,8,9 (6,5):1,2,3,4,5,6,7,8,9 (7,5):1,2,3,4,5,6,7,8,9 (8,5):1,2,3,4,5,6,7,8,9 (9,5):1,2,3,4,5,6,7,8,9
|
|
|
|
+ (1,6):1,2,3,4,5,6,7,8,9 (2,6):1,2,6,7,8,9 (3,6):1,2,6,7,8,9 (4,6):1,2,3,4,5,6,7,8,9 (5,6):1,2,3,4,5,6,7,8,9 (6,6):1,2,3,4,5,6,7,8,9 (7,6):1,2,3,4,5,6,7,8,9 (8,6):1,2,3,4,5,6,7,8,9 (9,6):1,2,3,4,5,6,7,8,9
|
|
|
|
+ (1,7):1,2,6,7,8,9 (2,7): (3,7):1,2,6,7,8,9 (4,7):1,2,4,5,6,7,8,9 (5,7):1,2,4,5,6,7,8,9 (6,7):1,2,4,5,6,7,8,9 (7,7):1,2,4,5,6,7,8,9 (8,7):1,2,4,5,6,7,8,9 (9,7):1,2,4,5,6,7,8,9
|
|
|
|
+ (1,8):1,2,6,7,8,9 (2,8): (3,8):1,2,6,7,8,9 (4,8):1,2,3,5,6,7,8,9 (5,8):1,2,3,5,6,7,8,9 (6,8):1,2,3,5,6,7,8,9 (7,8):1,2,3,5,6,7,8,9 (8,8):1,2,3,5,6,7,8,9 (9,8):1,2,3,5,6,7,8,9
|
|
|
|
+ (1,9):1,2,6,7,8,9 (2,9): (3,9):1,2,6,7,8,9 (4,9):1,2,3,4,6,7,8,9 (5,9):1,2,3,4,6,7,8,9 (6,9):1,2,3,4,6,7,8,9 (7,9):1,2,3,4,6,7,8,9 (8,9):1,2,3,4,6,7,8,9 (9,9):1,2,3,4,6,7,8,9
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ println!("RIGHT HERE:");
|
|
|
|
+ let g = solver.group.group(Groups::Cell, 3);
|
|
|
|
+ let pairs = solver.possible.find_pairs(g);
|
|
|
|
+ println!("Pairs [cell index 3]: {:?}", pairs);
|
|
|
|
+ // Pairs [cell index 3]: ([([0, 3, 6], [2, 3, 4])], true)
|
|
|
|
+
|
|
|
|
+ let expected: Vec<(Vec<usize>, Vec<u8>)> = vec![(vec![0, 3, 6], vec![2, 3, 4])];
|
|
|
|
+ assert_eq!(pairs, (expected, true));
|
|
|
|
+
|
|
|
|
+ // solver.finalize_cell(3);
|
|
|
|
+ // solver.possible.display();
|
|
}
|
|
}
|
|
|
|
|
|
#[test]
|
|
#[test]
|