コード例 #1
0
 /// <inheritdoc/>
 public bool TryConstrain(IReadOnlyPuzzle puzzle, ExactCoverGraph graph)
 {
     if (!Boxes.TryIntSquareRoot(puzzle.Size, out int boxSize))
     {
         return(false);
     }
     for (int box = 0; box < puzzle.Size; box++)
     {
         if (!_TryAppendRequirementsInBox(box, boxSize, puzzle, graph))
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #2
0
 public void TryIntSquareRoot_WithInvalidSize_ReturnsFalse(int puzzleSize)
 {
     Assert.False(Boxes.TryIntSquareRoot(puzzleSize, out _));
 }
コード例 #3
0
 public void TryIntSquareRoot_WithValidSizes_IsCorrect(int puzzleSize, int expectedBoxSize)
 {
     Assert.True(Boxes.TryIntSquareRoot(puzzleSize, out int boxSize));
     Assert.Equal(expectedBoxSize, boxSize);
 }