}//调用analize_group_deep方法 private void analize_group_shallow(Suduku_Group sg) { for (int i = 0; i < sg.Unsolved_Blank.Count; i++) { List <int> tmp_list = new List <int>(sg.Unsolved_Blank[i].iValues); for (int j = 0; j < sg.Unsolved_Blank.Count; j++) { if (i != j) { List <int> test_list = new List <int>(sg.Unsolved_Blank[j].iValues); for (int k = 0; k < sg.Unsolved_Blank[j].iValues.Count; k++) { tmp_list.Remove(test_list[k]); } } } if (tmp_list.Count == 1) { sg.Unsolved_Blank[i].Value = tmp_list[0]; solve_suduku(); break; } else if (tmp_list.Count > 1) { break; } } }
protected void init_comp(Suduku_Blank[] original_data) { if (original_data.Length == 81) { origin_suduku_values = new int[81]; for (int i = 0; i < 81; i++) { origin_suduku_values[i] = original_data[i].Value; } for (int i = 0; i < 81; i++) { Ori_Blank[i] = new Suduku_Blank(0, 0); Ori_Blank[i].Restore_Image(original_data[i]); } } for (int i = 0; i < 9; i++) { Row_Group[i] = new Suduku_Group(GroupType.Row, i, Ori_Blank); } for (int i = 0; i < 9; i++) { Column_Group[i] = new Suduku_Group(GroupType.Column, i, Ori_Blank); } for (int i = 0; i < 9; i++) { Mix_Group[i] = new Suduku_Group(GroupType.Mix, i, Ori_Blank); } }
protected void init_comp(string filepath) { origin_suduku_values = Suduku_DataReader.GetDataFromFile(filepath); if (origin_suduku_values.Length != 81) { this.switch_enable_status(); } if (this.Enabled == true) { for (int i = 0; i < 81; i++) { Ori_Blank[i] = new Suduku_Blank(i, origin_suduku_values[i]); } } for (int i = 0; i < 9; i++) { Row_Group[i] = new Suduku_Group(GroupType.Row, i, Ori_Blank); } for (int i = 0; i < 9; i++) { Column_Group[i] = new Suduku_Group(GroupType.Column, i, Ori_Blank); } for (int i = 0; i < 9; i++) { Mix_Group[i] = new Suduku_Group(GroupType.Mix, i, Ori_Blank); } }
public void Resutore_Image(Suduku_Group image) { this.Unsolved_Blank.Clear(); switch (this.GrpType) { case GroupType.Row: for (int i = 0; i < image.Unsolved_Blank.Count; i++) { this.Unsolved_Blank.Add(this.Blank[Index_Parser.Row_index(image.Unsolved_Blank[i].Index)]); } break; case GroupType.Column: for (int i = 0; i < image.Unsolved_Blank.Count; i++) { this.Unsolved_Blank.Add(this.Blank[Index_Parser.Column_index(image.Unsolved_Blank[i].Index)]); } break; case GroupType.Mix: for (int i = 0; i < image.Unsolved_Blank.Count; i++) { this.Unsolved_Blank.Add(this.Blank[Index_Parser.Mix_index(image.Unsolved_Blank[i].Index)]); } break; } }
public Suduku_Group Make_Image(Suduku_Blank[] Blk) { Suduku_Group Image_Copy = new Suduku_Group(this.GrpType, this.GroupIndex, Blk); for (int i = 0; i < this.Blank.Count; i++) { if (Blank[i].IsConformed == true) { Image_Copy.Unsolved_Blank.Remove(Blank[i]); } } return(Image_Copy); }
private void analize_group_deep(Suduku_Group sg) { bool success_flag = false; for (int i = 2; i <= sg.Unsolved_Blank.Count - 2; i++) { if (sg.Unsolved_Blank.Count >= i + 2) { for (int j = 0; j < sg.Unsolved_Blank.Count; j++) { if (sg.Unsolved_Blank[j].iValues.Count == i) { int counter = 1; List <int> sec_index = new List <int> { j }; List <int> test_ivalue = new List <int>(sg.Unsolved_Blank[j].iValues); for (int k = 0; k < sg.Unsolved_Blank.Count; k++) { if (k != j) { if (sg.Unsolved_Blank[k].iValues.Count <= i) { bool check = true; for (int l = 0; l < sg.Unsolved_Blank[k].iValues.Count; l++) { if (!test_ivalue.Contains(sg.Unsolved_Blank[k].iValues[l])) { check = false; break; } } if (check) { counter++; sec_index.Add(k); } } } if (counter == i) { break; } } if (counter == i) { for (int k = 0; k < sg.Unsolved_Blank.Count; k++) { if (!sec_index.Contains(k)) { for (int l = 0; l < test_ivalue.Count; l++) { if (sg.Unsolved_Blank[k].iValues.Remove(test_ivalue[l])) { success_flag = true; } } } } break; } } } } if (success_flag) { solve_suduku(); break; } } }