Created
April 26, 2017 08:08
-
-
Save Bambofy/b968f22f00ddffd4983960fbe811e570 to your computer and use it in GitHub Desktop.
This file contains 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.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace CodeADay | |
{ | |
class Program | |
{ | |
private static Dictionary<string, string> CharacterMappings = new Dictionary<string, string>(); | |
static void ConvertToLeet(ref string text) | |
{ | |
text = text.ToUpper(); | |
foreach (KeyValuePair<string, string> characterMap in CharacterMappings) | |
{ | |
text = text.Replace(characterMap.Key, characterMap.Value); | |
} | |
} | |
static void ConvertFromLeet(ref string text) | |
{ | |
foreach (KeyValuePair<string, string> characterMap in CharacterMappings) | |
{ | |
text = text.Replace(characterMap.Value, characterMap.Key).ToLower(); | |
} | |
} | |
static void Main(string[] args) | |
{ | |
CharacterMappings.Add("A", "4"); | |
CharacterMappings.Add("B", "6"); | |
CharacterMappings.Add("E", "3"); | |
CharacterMappings.Add("I", "1"); | |
CharacterMappings.Add("L", "|"); | |
CharacterMappings.Add("M", "(V)"); | |
CharacterMappings.Add("N", @"(\)"); | |
CharacterMappings.Add("O", "0"); | |
CharacterMappings.Add("S", "5"); | |
CharacterMappings.Add("T", "7"); | |
CharacterMappings.Add("V", @"\/"); | |
CharacterMappings.Add("W", "`//"); | |
bool loop = true; | |
while (loop) | |
{ | |
string mode = "0"; | |
while (mode != "1" || mode != "2") | |
{ | |
Console.Write("Convert to leet (enter 1) or from leet (enter 2): "); | |
mode = Console.ReadLine(); | |
} | |
if (mode == "1") | |
{ | |
Console.Write("Please enter some text to translate:"); | |
string text = Console.ReadLine(); | |
ConvertToLeet(ref text); | |
Console.WriteLine("-> {0}", text); | |
} | |
else if (mode == "2") | |
{ | |
Console.Write("Please enter some text to translate:"); | |
string text = Console.ReadLine(); | |
ConvertFromLeet(ref text); | |
Console.WriteLine("-> {0}", text); | |
} | |
Console.Write("Would you like to continue? Y/N: "); | |
string cont = Console.ReadLine(); | |
if (cont.ToUpper() == "N") | |
{ | |
loop = false; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment