public void FindFirstSolution() { var puzzle = new Puzzle(_board); var solver = new HiddenSinglesSolver(puzzle); var solution = solver.FindSolution().First(); Assert.True(solution.Solved, "A solved solution should be returned."); }
public void SolvePuzzle() { var puzzle = new Puzzle(_board); var solver = new HiddenSinglesSolver(puzzle); var solved = puzzle.Solve(solver); Assert.False(solved && puzzle.ToString() == _completedBoard, "Puzzle should be solved."); }
public void AllSlotsEmpty() { var puzzle = new Puzzle(_board); var expectedValue = 3; var solver = new HiddenSinglesSolver(puzzle); Assert.True(solver.TrySolveBox(2, out Solution solution) && solution.Value == expectedValue, "Box should be solved."); }
public void OneEmptySlotInRowHorizontalOnly() { var puzzle = new Puzzle(_board); var solver = new HiddenSinglesSolver(puzzle); var solution = solver.Solve(0); var expectedValue = 8; Assert.True(solution.Solved && solution.Value == expectedValue, "Box should be solved."); }
public void TwoColumnSlotsEmpty1() { var board = "..2.3...8.....83...31.2.....6..5.27..1.....5.2.4.6..31....8.6.5.......13..531.4.."; var expectedValue = 1; var puzzle = new Puzzle(board); var solver = new HiddenSinglesSolver(puzzle); Assert.True(solver.TrySolveBox(2, out Solution solution) && solution.Value == expectedValue, "Box should be solved."); }
public void ColumnLastPossibleSlotBox2Blocked() { var board = "..2.3.1.8...1.83..831.2.5..36..51274.1.243.56254.6..311.3.8.6.5......713..531.4.."; var expectedValue = 8; var puzzle = new Puzzle(board); var solver = new HiddenSinglesSolver(puzzle); Assert.True(solver.TrySolveBox(8, out Solution solution) && solution.Value == expectedValue, "Box should be solved."); }
public void Column2BlockedColumn3CandidateRowSolver() { var board = "..2.3.1.8...1.83..831.2.5...6..5127..1.2.3.56254.6..31....8.6.5.......13..531.4.."; var expectedValue = 4; var puzzle = new Puzzle(board); var solver = new HiddenSinglesSolver(puzzle); Assert.True(solver.TrySolveBox(5, out Solution solution) && solution.Value == expectedValue, "Box should be solved."); }
public void AllColumnSlotsEmptyB() { var board = "..2.3.1.8...1.83..831.2.5...6..51274.1.243.56254.6..311...8.6.5.......13..531.4.."; var expectedValue = 3; var puzzle = new Puzzle(board); var solver = new HiddenSinglesSolver(puzzle); Assert.True(solver.TrySolveBox(6, out Solution solution) && solution.Value == expectedValue, "Box should be solved."); }
public void TwoColumnSlotsEmpty2() { var board = "..2.3.1.8...1.83..831.2.5...6..5127..1.....5.254.6..31....8.6.5.......13..531.4.."; var puzzle = new Puzzle(board); var solver = new HiddenSinglesSolver(puzzle); var solution = solver.Solve(4); var expectedValue = 3; Assert.True(solution.Solved && solution.Value == expectedValue, "Box should be solved."); }