Lawnmover.Pattern.GetMinUnsolved C# (CSharp) Method

GetMinUnsolved() public method

public GetMinUnsolved ( ) : Cell
return Cell
        public Cell GetMinUnsolved()
        {
            Cell result = null;

            for (int x = 0; x < width; x++)
                for (int y = 0; y < height; y++)
                {
                    if (this.IsSolved(y, x))
                        continue;
                    int value = this.cells[y, x];
                    if (result == null || result.Value > value)
                        result = new Cell() { Row = y, Column = x, Value = value };
                }

            return result;
        }

Usage Example

Esempio n. 1
0
        public void GetMinUnsolved()
        {
            Pattern pattern = new Pattern(2, 2);

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

            var result = pattern.GetMinUnsolved();

            Assert.IsNotNull(result);
            Assert.AreEqual(0, result.Row);
            Assert.AreEqual(0, result.Column);
            Assert.AreEqual(1, result.Value);
        }