public void InnerShellBoxLineReduction(List<Cell> cells)
        {
            bool[] matchBool = new bool[9];
            for (int i = 0; i < 9; i++) matchBool[i] = true;
            List<Box> candPlace = new List<Box>();
            for (int i = 0; i < 9; i++)
            {
                Box temp = new Box();
                candPlace.Add(temp);
            }
            int[] candCount = new int[9];

            foreach (var cell in cells)
                if (cell.Value == 0)
                    foreach (var cand in cell.Candidates)
                    {
                        if (candCount[cand - 1] == 0)
                        {
                            candPlace[cand - 1] = cell.Box;
                        }
                        else
                        {
                            if (!candPlace[cand - 1].Equals(cell.Box)) matchBool[cand - 1] = false;
                        }
                        candCount[cand - 1]++;
                    }

            for (int i = 0; i < 9; i++)
                if (candCount[i] < 2) matchBool[i] = false;

            for (int i = 0; i < 9; i++)
                if (matchBool[i])
                    InnerCoreBoxLineReduction(candPlace[i].Cells, i + 1, cells);
        }
Ejemplo n.º 2
0
 public Cell(int x, int y, int value)
 {
     X = x;
     Y = y;
     Value = value;
     Box = new Box();
     candidates = new List<int>();
 }
 private void InnerPointingPair(List<Cell> cells, int a, Box except)
 {
     foreach (var cell in cells)
         if (!cell.Box.Equals(except))
         {
             if (cell.Candidates.Count > 0 && cell.Candidates.Contains(a))
             {
                 cell.RemoveCandidateIfExist(a);
                 cell.Candidates.Sort();
                 cell.Panel.Refresh();
                 isChanged = true;
             }
             else isChanged = false;
         }
 }
        private List<Box> ParseBox(String box)
        {
            List<Box> boxes = new List<Box>();

            for (int i = 0; i < 9; i++)
            {
                Box tempBox = new Box();
                boxes.Add(tempBox);
            }

            for (int y = 0; y < 9; y++)
            {
                for (int x = 0; x < 9; x++)
                {
                    int boxID;
                    if (int.TryParse(Convert.ToString(box[x + y * 9]), out boxID))
                    {
                        Cell cell = tableController.Table.Cells.ElementAt(y).ElementAt(x);
                        boxes[boxID - 1].Cells.Add(cell);
                        cell.Box = boxes[boxID - 1];
                    }
                }
            }
            return boxes;
        }