namespace EndMove.Sudoku.Solver.Core.Algorithms; public abstract class SolverBase : ISolver { internal readonly Action DisplayBoard; /// /// Constructor for base solver algorithms /// /// Method to display board in terminal or other protected SolverBase(Action displayBoard) { DisplayBoard = displayBoard; } public virtual bool IsValid(int[,] board, int row, int col, int n) { // Check Col, Row for (int i = 0; i < 9; i++) { if (board[row, i] == n || board[i, col] == n) { return false; } } // Check Box int xSize = (col / 3) * 3, ySize = (row / 3) * 3; for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { if (board[ySize + y, xSize + x] == n) { return false; } } } return true; } public virtual bool IsValid(int[] board, int row, int col, int n) { throw new NotImplementedException(); } public abstract (bool, int[,]) Solve(int[,] board); public abstract (bool, int[]) Solve(int[] board); }