Skip to content

Instantly share code, notes, and snippets.

@savaged
Last active October 21, 2022 08:15
Show Gist options
  • Save savaged/0cbbc22866883f1e8b7552e61f0c7a80 to your computer and use it in GitHub Desktop.
Save savaged/0cbbc22866883f1e8b7552e61f0c7a80 to your computer and use it in GitHub Desktop.
Caesar Cipher in C# (with Linq)
if (args?.Count() > 0)
Console.WriteLine(args[0].Select(c =>
c switch
{
>= 'a' and <= 'm' or >= 'A' and <= 'M' => (char)(c + 13),
>= 'n' and <= 'z' or >= 'N' and <= 'Z' => (char)(c - 13),
_ => c
}
).ToArray());
@savaged
Copy link
Author

savaged commented Oct 12, 2022

@savaged
Copy link
Author

savaged commented Oct 21, 2022

The Challenge

Caesar Cipher in the least procedural way (with extra points for the least number of semi-colons).

TDD

> Rot13 Test13!
> Grfg13!
> Rot13 Grfg13!
> Test13!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment