Advertisement
minalmisal

Untitled

Nov 13th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Implement a palindrome checker to make the following test cases pass. This starter code is in C# but you are welcome to write your solution in any language
  2.  
  3. using System.Linq;
  4.  
  5. bool IsPalindrome(string s){
  6.     //return false; // todo
  7.    // Below is the changed code
  8.    return s.SequenceEqual(s.Reverse());
  9. }
  10.  
  11. void Check(string s, bool shouldBePalindrome){
  12.     Console.WriteLine(IsPalindrome(s) == shouldBePalindrome ? "pass" : "FAIL");  
  13. }
  14.  
  15. void Main()
  16. {
  17.     Check("abcba", true);
  18.     Check("abcde", false);
  19.     Check("Mr owl ate my metal worm", true);
  20.     Check("Never Odd Or Even", true);
  21.     Check("Never Even Or Odd", false);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement