fork(3) download
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace ConsoleApplication2
  5. {
  6. class Program
  7. {
  8. static bool IsPalindrome(string s)
  9. {
  10. // the code:
  11. var x=s.ToLower().Where(char.IsLetterOrDigit);return x.SequenceEqual(x.Reverse());
  12. }
  13.  
  14. static void Main()
  15. {
  16. TestPalindrome("racecar");
  17. TestPalindrome("rAceCaR");
  18. TestPalindrome("ra1cecar");
  19. TestPalindrome("ra1cec1ar");
  20. TestPalindrome("ra1c\te.c;1ar");
  21. }
  22.  
  23. static void TestPalindrome(string s)
  24. {
  25. Console.WriteLine("[{0}] is {1}a palindrome", s, IsPalindrome(s) ? "" : "not ");
  26. }
  27. }
  28. }
  29.  
Success #stdin #stdout 0.04s 34080KB
stdin
Standard input is empty
stdout
[racecar] is a palindrome
[rAceCaR] is a palindrome
[ra1cecar] is not a palindrome
[ra1cec1ar] is a palindrome
[ra1c	e.c;1ar] is a palindrome