public void OnPuzzleCompleted(object sender, PuzzleEventArgs e) { List <string> wordList = new List <string>(); Node currentNode = e.Node; while (!currentNode.IsStartNode) { wordList.Add(currentNode.Word); currentNode = currentNode.ParentNode; } wordList.Add(currentNode.Word); wordList.Reverse(); int wordNo = 1; foreach (var w in wordList) { Console.WriteLine($"{wordNo++}: {w}"); } _fileUtility.ResultsToFile(_outputPath, wordList); }