Lawnmover.Pattern.HasSolution C# (CSharp) Méthode

HasSolution() public méthode

public HasSolution ( ) : bool
Résultat bool
        public bool HasSolution()
        {
            Cell cell = this.GetMinUnsolved();

            if (cell == null)
                return true;

            if (this.IsValidRowMove(cell.Row, cell.Value))
            {
                this.MoveRow(cell.Row, cell.Value);
                if (this.HasSolution())
                    return true;
                this.MoveRow(cell.Row, 0);
            }

            if (this.IsValidColumnMove(cell.Column, cell.Value))
            {
                this.MoveColumn(cell.Column, cell.Value);
                if (this.HasSolution())
                    return true;
                this.MoveColumn(cell.Column, 0);
            }

            return false;
        }

Usage Example

Exemple #1
0
        public void HasSolution3x1()
        {
            Pattern pattern = new Pattern(3, 1);

            pattern.SetRow(0, "1 2 1");

            Assert.IsTrue(pattern.HasSolution());
        }
All Usage Examples Of Lawnmover.Pattern::HasSolution