Last active
December 18, 2015 11:29
-
-
Save vcsjones/5776232 to your computer and use it in GitHub Desktop.
ROT13
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
private static string Rot13(string inputText) | |
{ | |
return new string(inputText.Select(c => | |
{ | |
var lower = Char.ToLower(c); | |
if (lower >= 'a' && lower <= 'z' && lower > 'm') return (char)(c - 13); | |
if (lower >= 'a' && lower <= 'z') return (char)(c + 13); | |
return c; | |
}).ToArray()); | |
} |
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
let rot13 (inputText:string) = | |
new string(inputText |> Seq.map(fun x -> | |
let lower = System.Char.ToLower(x) | |
match lower with | |
| c when c >= 'a' && c <= 'z' && c > 'm' -> int x-13 |> char | |
| c when c >= 'a' && c <= 'z' -> int x+13 |> char | |
| _ -> x | |
) |> Seq.toArray) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment