public Cell(int x, int y, int value) { X = x; Y = y; Value = value; Box = new Box(); candidates = new List<int>(); }
private void InitializeTable() { output = new int[27, 27]; table = new Table(); boxes = new List<Box>(); // for (int i = 0; i < 9; i++) boxes.Add(new Box()); for (int y = 0; y < 9; y++) { List<Cell> row = new List<Cell>(); Box tempBox = new Box(); for (int x = 0; x < 9; x++) { List<int> candidate = new List<int>(); Cell cell = new Cell(x, y, (int)((x + 1) * (y + 1)) % 9); for (int i = 1; i < 10; i++) candidate.Add(i); cell.Candidates = candidate; row.Add(cell); int boxIndex = (y / 3) + (x / 3) * 3; tempBox.Cells.Add(cell); } foreach (var cell in row) { cell.Box = tempBox; } table.Cells.Add(row); } CreateOutput(); Iteraction(); CreateOutput(); }