public void TestExampleFromDescription() { string decodeBits = MorseCodeDecoder.DecodeBits("1100110011001100000011000000111111001100111111001111110000000000000011001111110011111100111111000000110011001111110000001111110011001100000011"); Assert.AreEqual(".... . -.-- .--- ..- -.. .", decodeBits); Assert.AreEqual("HEY JUDE", MorseCodeDecoder.DecodeMorse(decodeBits)); }
public static string Decode(string morseCode) { morseCode = morseCode.Trim(); Console.WriteLine(morseCode); char[] delimiterChars = { ' ' }; string[] subCodes = morseCode.Split(delimiterChars); Dictionary <string, string> morse = MorseCodeDecoder.Codes(); string output; StringBuilder sb = new StringBuilder(); int i = 0; foreach (string code in subCodes) { if (morse.ContainsKey(code)) { morse.TryGetValue(code, out output); sb.Append(output); Console.WriteLine(output); } else { if (code.Length == 0 && i + 1 < subCodes.Length) { if (subCodes[i + 1].Length == 0) { sb.Append(" "); } } } i++; } return(sb.ToString()); }
static void Main(string[] args) { var test = "1100110011001100000011000000111111001100111111001111110000000000000011001111110011111100111111000000110011001111110000001111110011001100000011"; var out1 = MorseCodeDecoder.DecodeBits(test); Console.WriteLine(out1); System.Console.WriteLine(MorseCodeDecoder.DecodeMorse(out1)); }
static void Main(string[] args) { // for (int i = 'A'; i <= 'Z'; i++) // { // System.Console.WriteLine(@"{"",'" + (char)i + @"'},"); // } Console.WriteLine(MorseCodeDecoder.Decode("...---... -.-.-- - .... . --.- ..- .. -.-. -.- -... .-. --- .-- -. ..-. --- -..- .--- ..- -- .--. ... --- ...- . .-. - .... . .-.. .- --.. -.-- -.. --- --. .-.-.- ")); }
public void Decode_RegularString_CorrectResult() { string input = ".... . -.-- .--- ..- -.. ."; string expected = "HEY JUDE"; string actual = MorseCodeDecoder.Decode(input); Assert.AreEqual(expected, actual); }
public void Test1() { string input = ".... . -.-- .--- ..- -.. ."; string expected = "[L][L][L] [L][L][L][L]"; string actual = MorseCodeDecoder.Decode(input); Assert.AreEqual(expected, actual); }
public void MorseCodeDecoderBasicTest_1() { try { string input = ".... . -.-- .--- ..- -.. ."; string expected = "HEY JUDE"; string actual = MorseCodeDecoder.Decode(input); Assert.AreEqual(expected, actual); } catch (Exception ex) { Assert.Fail("There seems to be an error somewhere in your code. Exception message reads as follows: " + ex.Message); } }
public void DecodeMorseLetter_SingleLetter_CorrectResult() { var morseDictionary = new Dictionary <string, string> { { ".-", "A" }, { "-...", "B" }, { "-.-.", "C" }, { "-..", "D" }, { ".", "E" }, { "..-.", "F" }, { "--.", "G" }, { "....", "H" }, { "..", "I" }, { ".---", "J" }, { "-.-", "K" }, { ".-..", "L" }, { "--", "M" }, { "-.", "N" }, { "---", "O" }, { ".--.", "P" }, { "--.-", "Q" }, { ".-.", "R" }, { "...", "T" }, { "-", "S" }, { "..-", "U" }, { "...-", "V" }, { ".--", "W" }, { "-..-", "X" }, { "-.--", "Y" }, { "--..", "Z" }, { "-.-.--", "!" }, { ".-.-.-", "." }, { " ", " " }, }; Assert.Multiple(() => { foreach (var entry in morseDictionary) { var input = entry.Key; var expected = entry.Value; var actual = MorseCodeDecoder.DecodeMorseLetter(input); Assert.AreEqual(expected, actual); } }); }
public void MorseCodeDecoderComplexTest_3() { try { string input = " ...---... -.-.-- - .... . --.- ..- .. -.-. -.- -... .-. --- .-- -. ..-. --- -..- .--- ..- -- .--. ... --- ...- . .-. - .... . .-.. .- --.. -.-- -.. --- --. .-.-.- "; string expected = "SOS! THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG."; string actual = MorseCodeDecoder.Decode(input); Assert.AreEqual(expected, actual); } catch (Exception ex) { Assert.Fail("There seems to be an error somewhere in your code. Exception message reads as follows: " + ex.Message); } }
static void Main(string[] args) { Console.WriteLine(MorseCodeDecoder.Decode("...---...")); }
public void MorseCodeTest() { Assert.AreEqual("HEY JUDE", MorseCodeDecoder.Decode(".... . -.-- .--- ..- -.. .")); }
public void Decode_SOSCodeTester(string input, string expected) { var actual = MorseCodeDecoder.Decode(input); Assert.AreEqual(expected, actual); }
public void MySolution() { Assert.AreEqual("HEY JUDE", MorseCodeDecoder.DecodeMySolution(".... . -.-- .--- ..- -.. .")); Assert.AreEqual("SOS", MorseCodeDecoder.DecodeMySolution("...---...")); }
static void Main(string[] args) { var test = "0000000011011010011100000110000001111110100111110011111100000000000111011111111011111011111000000101100011111100000111110011101100000100000"; Console.WriteLine(MorseCodeDecoder.decodeBitsAdvanced(test)); }