public static void Main()
Console.WriteLine(np1.Length/2);
Console.WriteLine("help".IsPalindrome());
Console.WriteLine("deed".IsPalindrome());
Console.WriteLine("deeeeeed".IsPalindrome());
Console.WriteLine("dee ee eed".IsPalindrome());
Console.WriteLine("Dee eee eed".IsPalindrome());
Console.WriteLine("taco Cat".IsPalindrome());
public static class PalindromeExtension {
public static bool IsPalindrome(this string astring) {
astring = astring.Trim().Replace(" ","").ToLowerInvariant();
if (string.IsNullOrEmpty(astring)){
if (astring.Length % 2 == 0) {
front = astring.Substring(0,astring.Length/2);
back = astring.Substring(astring.Length/2);
Console.WriteLine($"front {front} back {back}");
return front.ReverseCompare(back);
front = astring.Substring(0,astring.Length/2);
back = astring.Substring(astring.Length/2+1);
Console.WriteLine($"front {front} back {back}");
return front.ReverseCompare(back);
public static bool ReverseCompare(this string left, string right) {
for (int i = 0; i < left.Length; i++){
if (left[i] != right[right.Length-1-i]) { return false; }
public static string FindLongestPalindrome(this string s){
if (string.IsNullOrEmpty(s)){
if (s.IsPalindrome()){ return s; }