/// <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); }
public void TryIntSquareRoot_WithInvalidSize_ReturnsFalse(int puzzleSize) { Assert.False(Boxes.TryIntSquareRoot(puzzleSize, out _)); }
public void TryIntSquareRoot_WithValidSizes_IsCorrect(int puzzleSize, int expectedBoxSize) { Assert.True(Boxes.TryIntSquareRoot(puzzleSize, out int boxSize)); Assert.Equal(expectedBoxSize, boxSize); }