Skip to content

Instantly share code, notes, and snippets.

@aopell
Created April 27, 2017 18:52
Show Gist options
  • Save aopell/c8a39f133c1d546dbb4a7c62d978b677 to your computer and use it in GitHub Desktop.
Save aopell/c8a39f133c1d546dbb4a7c62d978b677 to your computer and use it in GitHub Desktop.
C# Rot-N one-liner
static string rot(string s, int n) => return string.Concat(s.Select(x => (char)(x >= 'A' && x <= 'Z' ? (x + n > 'Z' ? x - 26 + n : x + n) : x >= 'a' && x <= 'z' ? (x + n > 'z' ? x - 26 + n : x + n) : x)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment