public NakedSinglesSolver(Puzzle puzzle)
 {
     _puzzle = puzzle;
 }
        public Solution SolveBox(int index)
        {
            var box = _puzzle.GetBox(index);

            var solution = new Solution
            {
                Solved = false
            };
            var values        = new bool[10];
            var unsolvedCells = 0;
            var unsolvedCell  = 99;

            for (int i = 0; i < 9; i++)
            {
                int value;
                if (i < 3)
                {
                    value = box.FirstRow[i];
                }
                else if (i < 6)
                {
                    value = box.InsideRow[i - 3];
                }
                else
                {
                    value = box.LastRow[i - 6];
                }

                if (value > 0)
                {
                    values[value] = true;
                }
                else
                {
                    unsolvedCells++;
                    unsolvedCell = i;
                }
                if (unsolvedCells > 1)
                {
                    return(solution);
                }
            }

            if (unsolvedCells == 0)
            {
                return(solution);
            }

            for (int i = 1; i < 10; i++)
            {
                if (!values[i])
                {
                    solution.Value = i;
                    break;
                }
            }

            (var row, var column) = Puzzle.GetLocationForBoxCell(index, unsolvedCell);

            solution.Solved = true;
            solution.Row    = row;
            solution.Column = column;
            solution.Solver = this;
            return(solution);
        }