Created
November 5, 2020 20:47
-
-
Save lomholdt/3a21e1fe202ec8f203e344cf02591119 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using static System.Text.Encoding; | |
public static class Program { | |
public static void Main() | |
{ | |
var result = IsPalindrome("racecar"); | |
} | |
public static bool IsPalindrome(string name) | |
{ | |
var half = name.Length / 2; | |
var bytes = ASCII.GetBytes(name); | |
return bytes.Take(half).SequenceEqual(bytes.Reverse().Take(half)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment