public void NewValue(object sender, EventArgs e) { SudokuBox box = (SudokuBox)sender; for (int i = 0; i < 9; i++) { if (Boxes[i] != box) { Boxes[i].Remove(box.Value); } } }
public SudokuPuzzle() { for (int c = 0; c < 9; c++) { SudokuGroup group = new SudokuGroup(); for (int r = 0; r < 9; r++) { Puzzle[c, r] = new SudokuBox(c, r); group.Boxes.Add(Puzzle[c, r]); } Groups.Add(group); } for (int r = 0; r < 9; r++) { SudokuGroup group = new SudokuGroup(); for (int c = 0; c < 9; c++) { group.Boxes.Add(Puzzle[c, r]); } Groups.Add(group); } for (int c_b = 0; c_b < 9; c_b += 3) { for (int r_b = 0; r_b < 9; r_b += 3) { SudokuGroup group = new SudokuGroup(); for (int c = c_b; c < c_b + 3; c++) { for (int r = r_b; r < r_b + 3; r++) { group.Boxes.Add(Puzzle[c, r]); } } Groups.Add(group); } } }