Exemplo n.º 1
0
        public void RowConstraintSuccessTest()
        {
            Sudoku        sudoku     = CreateTestSudoku();
            RowConstraint constraint = new RowConstraint();
            bool          result     = constraint.Evaluate(sudoku, xCoord: 2, yCoord: 0);

            Assert.IsTrue(result);
        }
Exemplo n.º 2
0
        public void RowConstraintFailureFullRowTest()
        {
            Sudoku sudoku = CreateTestSudoku();

            sudoku.SetValue(2, 0, 2).SetValue(3, 0, 3).SetValue(4, 0, 7).SetValue(6, 0, 8).SetValue(7, 0, 4);
            Output.Show(sudoku.Values);
            RowConstraint constraint = new RowConstraint();
            bool          result     = constraint.Evaluate(sudoku, xCoord: 2, yCoord: 0);

            Assert.IsFalse(result);
        }
Exemplo n.º 3
0
        public void RowConstraintFailTest()
        {
            Sudoku sudoku = CreateTestSudoku();

            sudoku.SetValue(2, 0, 5);  // Duplicate value in row 0
            Output.Show(sudoku.Values);
            RowConstraint constraint = new RowConstraint();
            bool          result     = constraint.Evaluate(sudoku, xCoord: 2, yCoord: 0);

            Assert.IsFalse(result);
        }
Exemplo n.º 4
0
        public void FindLockedSet()
        {
            var grid = new Grid(9);

            grid[6, 1].Candidates.Add(4, 9);
            grid[6, 2].Candidates.Add(6, 7);
            grid[6, 3].Candidates.Add(6, 7);
            grid[6, 4].PlaceDigit(8);
            grid[6, 5].Candidates.Add(3, 4, 7, 9);
            grid[6, 6].PlaceDigit(5);
            grid[6, 7].PlaceDigit(2);
            grid[6, 8].PlaceDigit(1);
            grid[6, 9].Candidates.Add(3, 6, 7, 9);

            var constraint = new RowConstraint(grid, 6);
            var lockedSets = constraint.FindLockedSets(2, false);
            var set        = lockedSets.Single();

            set[0].Candidates.Should().BeEquivalentTo((byte)6, (byte)7);
        }
Exemplo n.º 5
0
 public override string ToString()
 {
     return((DriveConstraint?.ToString() ?? "*") + ":" + (RowConstraint?.ToString() ?? "*") +
            (ColConstraint?.ToString() ?? "*"));
 }