Skip to content

Instantly share code, notes, and snippets.

@lomholdt
Created November 5, 2020 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lomholdt/3a21e1fe202ec8f203e344cf02591119 to your computer and use it in GitHub Desktop.
Save lomholdt/3a21e1fe202ec8f203e344cf02591119 to your computer and use it in GitHub Desktop.
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