static void Main(string[] args) { if (args.Length != 1) { Console.WriteLine("Command line format: PalindromeChallenge StringToCheck"); return; } var palindrome = new Palindrome(); // Get the Top 3 palindromes by text length var palindromes = palindrome.GetTopNPalindromes(args[0], 3); foreach (KeyValuePair <string, int> kvp in palindromes) { Console.WriteLine($"Text: {kvp.Key}, Index: {kvp.Value}, Length: {kvp.Key.Length}"); } }
public void AllPalindomeTestResults() { var testString = "sqrrqabccbatudefggfedvwhijkllkjihxymnnmzpop"; var palindrome = new Palindrome(); // Get the Top 3 palindromes by text length var palindromes = palindrome.GetTopNPalindromes(testString, 3); var palindromeKeys = palindromes.Keys.ToArray(); var palindromeIndices = palindromes.Values.ToArray(); Assert.AreEqual(palindromeKeys[0], "hijkllkjih"); Assert.AreEqual(palindromeIndices[0], 23); Assert.AreEqual(palindromeKeys[1], "defggfed"); Assert.AreEqual(palindromeIndices[1], 13); Assert.AreEqual(palindromeKeys[2], "abccba"); Assert.AreEqual(palindromeIndices[2], 5); }