Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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
- using System.Linq;
- bool IsPalindrome(string s){
- //return false; // todo
- // Below is the changed code
- return s.SequenceEqual(s.Reverse());
- }
- void Check(string s, bool shouldBePalindrome){
- Console.WriteLine(IsPalindrome(s) == shouldBePalindrome ? "pass" : "FAIL");
- }
- void Main()
- {
- Check("abcba", true);
- Check("abcde", false);
- Check("Mr owl ate my metal worm", true);
- Check("Never Odd Or Even", true);
- Check("Never Even Or Odd", false);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement