public Puzzle4() { allWords = DictReader.ReadDict("Dutch").Where(t => t.Length > 2).ToList(); allWords.AddRange(allWords.ToList().Select(t => t + "e")); Console.WriteLine("Filtering words"); allWords = allWords.Where(t => t.All(z => CharValueHelper.CharArray.Contains(z))).ToList(); Console.WriteLine("Done"); }
public void Go() { var grid = new Gridje <int>(5, 8); var data = new List <List <string> > { new List <string>() { "aachi" }, new List <string>() { "alntt", "bdttu" }, new List <string>() { "aelrw", "afitw" }, new List <string>() { "aemov", "afkmy" }, new List <string>() { "ansuv" }, new List <string>() { "anrst", "aopsu" }, new List <string>() { "cceen" }, new List <string>() { "airst" }, }; var combinations = data.Aggregate(1, (x, y) => x * y.Count); var numberListBase = new List <int>() { 0, 0, 0, 1, 2, 2, 1, 1, 2, 3, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 7, 6, 6, 5, 4, 4, 4, 3, 3, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5 }; //var numberListBase = new List<int>() //{ // 0, 0, 0, // 1, // 2, 2, // 1, 1, // 2, 3, 3, 4, 4, 5, // 5, 5, // 6, 6, 6, // 7, 7, 7, 7, 7, // 6, 6, // 5, 4, // 4, // 3, 3, // 2, 1, 0, // 0, 1, 2, 3, 4, 5 //}; //numberListBase.Reverse(); var allWorlds = DictReader.ReadDict("Dutch").Concat(DictReader.ReadDict("Voornamen")).ToArray(); //allWorlds = allWorlds.Select(t => t.ReverseString()).ToArray(); //var blah = allWorlds.Where(t => t.Contains("a") && t.Contains("i") && t.Contains("r") && t.Contains("s") && t.Contains("t")).ToList(); var corrects = new List <string>() { "acht", //"van", //"scenarist", //"massa", //"", //"wens", //"opeens", }; var filtered = new HashSet <string>(); for (int i = 0; i < combinations; i++) { Console.WriteLine($"Attempt: {i}"); var part1 = GetLijst(data, i); var part2 = ToCharList(part1); var numberListToWorkWith = numberListBase.ToList(); for (int zz = 0; zz < corrects.Count + 1; zz++) { bool foundhere = false; for (int y = 0; y < allWorlds.Length; y++) { var theDataToWorkWith = Clone(part2); var curWord = allWorlds[y]; bool completed = true; for (int z = 0; z < curWord.Length; z++) { var nr = numberListToWorkWith[z]; var curChar = curWord[z]; if (theDataToWorkWith[nr].Contains(curChar)) { theDataToWorkWith[nr].Remove(curChar); } else { completed = false; break; } } if (completed) { if (zz >= corrects.Count) { Console.WriteLine($"Cycle: {zz}, Potential: {curWord}"); filtered.Add(curWord); } if (zz < corrects.Count) { if (curWord == corrects[zz]) { part2 = theDataToWorkWith; numberListToWorkWith = numberListToWorkWith.Skip(curWord.Length).ToList(); foundhere = true; //if (zz == 0) //{ // AddToChars(part2, 8); //} } } } } if (!foundhere) { break; } Console.WriteLine(); } //LogList(part2); Console.WriteLine(); } Console.WriteLine("Filtered:"); foreach (var word in filtered.OrderBy(t => t.Length).ThenBy(t => t)) { //word = word.ReverseString(); Console.WriteLine(word); } }