private string GetId(string number, Dictionary<string, DmDPC> dict) { string numberId = string.Empty; var digits = number.Trim().ToArray(); Permutations<char> perm = new Permutations<char>(digits, number.Trim().Length); List<string> arranges = perm.Get(""); foreach (var arrange in arranges) { if (!dict.ContainsKey(arrange)) continue; numberId = arrange; break; } return numberId; }
private string GetId(string number,string numberType, Dictionary<string, DmDPC> dict) { if (!numberType.Contains("Z")) return this.GetId(number, dict); string numberId = string.Empty; var digits = number.Trim().ToList(); Permutations<int> perm = new Permutations<int>(digits, digits.Count); List<string> arranges = perm.Get(""); foreach (var arrange in arranges) { if (!dict.ContainsKey(arrange)) continue; numberId = arrange; break; } return numberId; }
/// <summary> /// 可重复组合 /// </summary> public static void Cr(string name, string type, int length, string output) { List<List<int>> lists = length == 2 ? GetPr2() : GetPr3(); List<string> clist = new List<string>(360); foreach (var list in lists) { Permutations<int> p = new Permutations<int>(list, length); List<string> pn = p.Get(","); if (pn.Exists(x => clist.Contains(x))) continue; clist.Add(list.Format(",")); } if (output.Equals("txt")) { SaveToText(name, type, clist); return; } SaveToDB(name, type, clist); }
public static void C(string name, string type, int length, string output) { int count = (int)Math.Pow(10, length); List<string> list = new List<string>(10000); string format = "D" + length; for (int i = 0; i < count; i++) { var digits = i.ToString(format).ToArray(); Permutations<char> p = new Permutations<char>(digits, length); List<string> pn = p.Get(","); if (pn.Exists(x => list.Contains(x))) continue; list.Add(i.Format(format, ",")); } if (output.Equals("txt")) { SaveToText(name, type, list); return; } SaveToDB(name, type, list); }