25 lines
932 B
C#
25 lines
932 B
C#
class Program {
|
|
static void Main() {
|
|
// get all the words form the text file and put them into a hasset
|
|
var words = new List<string>(File.ReadAllLines("input.txt"));
|
|
var wordSet = new HashSet<string>(words);
|
|
|
|
// Find all combos that forn a 6 letter word and make sure we dont have duplicates
|
|
var seenCombinations = new HashSet<string>();
|
|
var combos = words.SelectMany(
|
|
word1 => words.Where(word2 => word1 != word2),
|
|
(word1, word2) => new { word1, word2, combinedWord = word1 + word2 }
|
|
).Where(
|
|
x => x.combinedWord.Length == 6 && wordSet.Contains(x.combinedWord)
|
|
).Where(
|
|
x => seenCombinations.Add($"{x.word1}+{x.word2}")
|
|
).Select(
|
|
x => $"{x.word1}+{x.word2}={x.combinedWord}"
|
|
).ToList();
|
|
|
|
// echo out all found words
|
|
combos.ForEach(Console.WriteLine);
|
|
|
|
}
|
|
}
|