private void EliminateNakedPairFromOthersInGroup(int[,] sodokuBoard, int givenRow, int givenCol)
        {
            if (!HasNakedPairInGroup(sodokuBoard, givenRow, givenCol))
            {
                return;
            }

            var sodokuMap = _sodokuMapper.Find(givenRow, givenCol);

            for (int row = sodokuMap.StartRow; row <= sodokuMap.StartRow + 2; row++)
            {
                for (int col = sodokuMap.StartCol; col <= sodokuMap.StartCol + 2; col++)
                {
                    if (sodokuBoard[row, col].ToString().Length > 1 && sodokuBoard[row, col] != sodokuBoard[givenRow, givenCol])
                    {
                        EliminateNakedPair(sodokuBoard, sodokuBoard[givenRow, givenCol], givenRow, givenCol);
                    }
                }
            }
        }
Beispiel #2
0
        private int GetPossibilitiesInGroup(int[,] sodokuBoard, int givenRow, int givenCol)
        {
            int[] possibilities = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            var   sodokuMap     = _sodokuMapper.Find(givenRow, givenCol);

            for (int row = sodokuMap.StartRow; row <= sodokuMap.StartRow + 2; row++)
            {
                for (int col = sodokuMap.StartCol; col <= sodokuMap.StartCol + 2; col++)
                {
                    if (IsValidSingle(sodokuBoard[row, col]))
                    {
                        possibilities[sodokuBoard[row, col] - 1] = 0;
                    }
                }
            }
            return(Convert.ToInt32(String.Join(string.Empty, possibilities.Select(p => p).Where(p => p != 0))));
        }