Example #1
0
        public void PossibleWords_StartAndEndPassed_ReturnsPossibleCombinations1()
        {
            // Arrange
            var startWord = "spin";
            var endWord   = "spot";

            var data = new List <string>
            {
                "s",
                "sp",
                "spi",
                "spo",
                "spin",
                "spit",
                "spon",
                "spot"
            };

            // Act
            var result = _wordHandler.PossibleWords(startWord, endWord, 4);

            Assert.That(result, Is.EquivalentTo(data));
        }
Example #2
0
        /// <summary>
        /// Returns shortest list of four letter words.
        /// </summary>
        /// <param name="dictionaryFile">Source file</param>
        /// <param name="startWord">4 letter starting word</param>
        /// <param name="endWord">4 letter ending word</param>
        /// <param name="resultFile">Final output file</param>
        public void ProcessWords(string dictionaryFile, string startWord, string endWord,
                                 string resultFile)
        {
            try
            {
                var possibleWordCombinations = _wordHandler.PossibleWords(startWord, endWord, _wordsLength);

                PossibleWordCombinationsSearch(dictionaryFile, possibleWordCombinations);

                GenerateResultFile(resultFile);
            }
            catch (Exception e)
            {
                // Log
                Console.WriteLine(e);
                throw;
            }
        }