added toggle-able notes and and basic button functionality to cell's

This commit is contained in:
Josh Ashton
2024-03-23 22:15:15 -06:00
parent 5e3c4151a6
commit fa3dbf32e2
5 changed files with 85 additions and 34 deletions
+28 -1
View File
@@ -40,9 +40,10 @@ public class SudokuChecker {
public Cell[][] getPossibleValues(Cell[][] grid) {
for(int row = 0; row < grid.length; row++) {
for(int col = 0; col < grid[row].length; col++) {
if(grid[row][col].getValue() == 0)
if(grid[row][col].getValue() != 0)
continue;
// Replace intersection with union?
ArrayList<Integer> intersection = intersection(
getRowRemainingNumbers(row),
getColRemainingNumbers(col)
@@ -65,6 +66,7 @@ public class SudokuChecker {
}
}
this.grid = grid;
return grid;
}
@@ -99,6 +101,31 @@ public class SudokuChecker {
return intersection;
}
/**
* Determine what numbers are available to be placed in the given cell of
* the grid. This is effectively an union of the numbers available in the
* row, column, and box of the cell.
*
* @param row
* @param col
*/
private ArrayList<Integer> union(
ArrayList<Integer> a,
ArrayList<Integer> b
) {
ArrayList<Integer> union = new ArrayList<Integer>();
for(int i = 0; i < a.size(); i++) {
union.add(a.get(i));
}
for(int i = 0; i < b.size(); i++) {
if(!union.contains(b.get(i))) {
union.add(b.get(i));
}
}
return union;
}
/**
* Determine what numbers are available to be placed in the given cell of
* the grid. This is effectively an intersection of the numbers available