Пример #1
0
        private bool FindSolution(Board board, int index)
        {
            int row = index/SIZE, column = index%SIZE;

            if (index == SIZE*SIZE) return true;

            if (board.IsFilled(row, column))  return FindSolution(board, index+1);

            foreach(int value in board.GetOptionsForCell(row, column))
            {
                board.SetCellValue(row, column, value);
                if (FindSolution(board, index+1)) return true;
            }
            board.ClearCell(row, column);

            return false;
        }