public void Run(string[] args) { if (args.Length != 4) { Console.WriteLine($"Only {args.Length} arguments supplied on the command line."); Console.WriteLine("Please use: WordLadder DictionaryFile StartWord EndWord ResultFile"); } try { string dictionaryFileName = args[0]; string startWord = args[1]; string endWord = args[2]; string ladderFileName = args[3]; var dictionary = _fileIO.ParseFile(dictionaryFileName); var graph = _grapgBuilder.BuildGraph(dictionary); var distances = _ladderBuilder.FindDistances(startWord, endWord, graph); var path = _ladderBuilder.BuildPath(startWord, endWord, distances); bool saved = _fileIO.SaveLadder(path, ladderFileName); if (saved) { Console.WriteLine($"Saved the word ladder to {ladderFileName}."); } else { Console.WriteLine("Failed to create the ladder."); } } catch (Exception e) { Console.WriteLine("Error calculating the ladder."); Console.WriteLine($"{e.Message} at {e.StackTrace}"); } }