Ejemplo n.º 1
0
        private IList <IList <IList <int> > > GetRowsPermutationsUncached(Sudoku Sudoku)

        {
            var toReturn = new List <IList <IList <int> > >(9);

            for (int i = 0; i < 9; i++)

            {
                var tempList = new List <IList <int> >();

                foreach (var perm in AllPermutations)

                {
                    if (!Range9.Any(j => Sudoku.Cells[i * 9 + j] > 0

                                    && (perm[j] != Sudoku.Cells[i * 9 + j])))

                    {
                        tempList.Add(perm);
                    }
                }

                toReturn.Add(tempList);
            }



            return(toReturn);
        }
        private IList <IList <IList <int> > > GetRowsPermutationsUncached(SudokuBoard sudokuBoard)
        {
            var toReturn = new List <IList <IList <int> > >(9);

            for (int i = 0; i < 9; i++)
            {
                var tempList = new List <IList <int> >();
                foreach (var perm in AllPermutations)
                {
                    if (!Range9.Any(j => sudokuBoard.GetCell(i, j) > 0 &&
                                    (perm[j] != sudokuBoard.GetCell(i, j))))
                    {
                        tempList.Add(perm);
                    }
                }
                toReturn.Add(tempList);
            }

            return(toReturn);
        }
Ejemplo n.º 3
0
        private IList <IList <IList <int> > > GetRowsPermutationsUncached(GrilleSudoku objSudoku)
        {
            var toReturn = new List <IList <IList <int> > >(9);

            for (int i = 0; i < 9; i++)
            {
                var tempList = new List <IList <int> >();
                foreach (var perm in AllPermutations)
                {
                    // Permutation should match current mask row numbers, and have numbers different that other mask rows
                    if (!Range9.Any(rowIdx => Range9.Any(j => objSudoku.GetCellule(rowIdx, j) > 0 &&
                                                         ((rowIdx == i && perm[j] != objSudoku.GetCellule(rowIdx, j)) || (rowIdx != i && perm[j] == objSudoku.GetCellule(rowIdx, j))))))
                    {
                        tempList.Add(perm);
                    }
                }
                toReturn.Add(tempList);
            }

            return(toReturn);
        }