Advertisement
mdamyanova

Palindrome Index

Jun 7th, 2016
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. sing System;
  2.  
  3. namespace _10.PalindromeIndex
  4. {
  5.     using System.Linq;
  6.  
  7.     public class PalindromeIndex
  8.     {
  9.         public static void Main()
  10.         {
  11.             string word = Console.ReadLine().ToLower();
  12.             string reversed = new string(word.Reverse().ToArray());
  13.  
  14.             if (word == reversed)
  15.             {
  16.                 Console.WriteLine("-1");
  17.             }
  18.             else
  19.             {
  20.                 foreach (var letter in word)
  21.                 {
  22.                     string tempWord = word.Remove(word.IndexOf(letter), 1);
  23.                     reversed = new string(tempWord.Reverse().ToArray());
  24.                     if (tempWord == reversed)
  25.                     {
  26.                         Console.WriteLine(word.IndexOf(letter));
  27.                         break;
  28.                     }
  29.                 }
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement