private async Task <long> RunAndMeasureElapsedMs() { string morse = "--.----.......-.---.--......-.."; ISet <string> dictionary = new HashSet <string> { "GOD", "IS", "NO", "NOW", "HERE", "WHERE", "HER", "GO", "ME", "MED", "MOD", "MO", }; this.decoder = new MorseDecoder() { MorseSequence = morse, FirstLetters = MorseDecoderTests.GetFirstLetters(dictionary), WordsByFirstLetter = MorseDecoderTests.GetWordsByFirstLetter(dictionary) }; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); await this.decoder.DecodeMorseSequenceAsync(); stopwatch.Stop(); return(stopwatch.ElapsedMilliseconds); }
private static void Main() { IInputReader inputReader = Program.GetInputReader(); string L = inputReader.ReadLine(); int N = int.Parse(inputReader.ReadLine()); MorseDecoder decoder = new MorseDecoder(); for (int i = 0; i < N; i++) { string W = inputReader.ReadLine(); if (!decoder.WordsByFirstLetter.ContainsKey(W[0])) { decoder.WordsByFirstLetter[W[0]] = new HashSet <string>(); } decoder.WordsByFirstLetter[W[0]].Add(W); decoder.FirstLetters.Add(W[0]); } inputReader.Dispose(); Console.WriteLine(decoder.DecodeAndReturnMessagesCountAsync(L).GetAwaiter().GetResult()); Console.Read(); }
public static void TestMeliMessage() { string meliMessage = "000000001101101100111000001111110001111110011111100000001110111111110111011100000001100011111100000111111001111110000000110000110111111110111011100000011011100000000000"; string morseMessage = MorseDecoder.decodeBits2Morse(meliMessage); Console.WriteLine(morseMessage); Console.WriteLine(MorseDecoder.translate2Human(morseMessage)); }
static void Main(string[] args) { bool continueMessage = true; string message = string.Empty; //TestMeliMessage(); //Console.ReadKey(); do { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); string inputStr = Console.ReadLine(); stopwatch.Stop(); long pause = (stopwatch.ElapsedMilliseconds / 800); string zeros = string.Empty; for (int i = 0; i < pause; i++) { zeros += "0"; } message += inputStr + zeros; Console.Clear(); Console.Write(message); continueMessage = pause < 10; } while (continueMessage); string morseParagraph = MorseDecoder.decodeBits2Morse(message); List <string> wordsToTRanslate = morseParagraph.Split(MorseDecoder.LetterSeparator).ToList(); string traslated = string.Empty; foreach (var item in wordsToTRanslate) { string letter = MorseDecoder.TranslateMorseToLetter(item); if (letter == "stop") { break; } traslated += letter; } Console.WriteLine($"Decoded : {morseParagraph}"); Console.WriteLine($"Input Traslated: {traslated}"); Console.ReadLine(); }
public void Setup() { ISet <string> dictionary = MorseDecoderTests.GetDefaultDictionary(); this.decoder = new MorseDecoder() { MorseSequence = "--.----.......-.---.--......-..", FirstLetters = MorseDecoderTests.GetFirstLetters(dictionary), WordsByFirstLetter = MorseDecoderTests.GetWordsByFirstLetter(dictionary) }; }
public IActionResult TranslateToMorse(MorseRequest request) { return(ExecuteResponse(() => { MorseResponse morseResponse = new MorseResponse(); morseResponse.Response = MorseDecoder.traslate2Morse(request.Text); morseResponse.Code = StatusCodes.Status200OK; return morseResponse; })); }
public void WriteToOutputFile() { MorseDecoder decoder = new MorseDecoder(); decoder.Decode("../Files/input.txt", "../Files/outputTest.txt"); FileInfo fileInfo = new FileInfo("../Files/outputTest.txt"); if (fileInfo.Length > 0) { Assert.IsFalse(false); } else { Assert.IsFalse(true); } }
public async Task TestHelloWorld() { ISet <string> dictionary = new HashSet <string> { "HELL", "HELLO", "OWORLD", "WORLD", "TEST" }; this.decoder = new MorseDecoder() { MorseSequence = "......-...-..---.-----.-..-..-..", FirstLetters = MorseDecoderTests.GetFirstLetters(dictionary), WordsByFirstLetter = MorseDecoderTests.GetWordsByFirstLetter(dictionary) }; await this.decoder.DecodeMorseSequenceAsync(); Assert.AreEqual(2, this.decoder.DecodedMessageCount); }
public void TestDecodeMorse() { string morse = "--.-"; ISet <string> dictionary = new HashSet <string> { "MA", "G", "M", "A", "T", "TNT" }; this.decoder = new MorseDecoder() { FirstLetters = MorseDecoderTests.GetFirstLetters(dictionary), WordsByFirstLetter = MorseDecoderTests.GetWordsByFirstLetter(dictionary) }; ISet <KeyValuePair <string, string> > result = this.decoder.DecodeMorse(morse); Assert.AreEqual(6, result.Count); }
static void Main(string[] args) { Console.WriteLine("Please enter the path to the file with the morse code: "); string inputPath = Console.ReadLine(); Console.WriteLine("Please enter the path to the file into which the decoded text should be written: "); string outputPath = Console.ReadLine(); try { MorseDecoder md = new MorseDecoder(); md.Decode(inputPath, outputPath); } catch (Exception e) { Console.Error.WriteLine(e.Message); } Console.WriteLine("Press any key to continue"); Console.ReadKey(); }
public static void readFromFile(string input, string output) { char ch = ' '; string code = " "; StreamReader reader = new StreamReader(input); StreamWriter writer = new StreamWriter(output); MorseDecoder decoder = new MorseDecoder(); while (!reader.EndOfStream) { ch = (char)reader.Read(); if (ch != '\n' && ch != '\r') { try { string let = Char.ToString(ch); let = let.ToUpper(); code = decoder.getMorseFromLetter(let); code = code + " "; } catch (Exception e) { Console.WriteLine("Wrong Character!" + (int)ch); } } else { code = ch + ""; } //Hinausschreiben writer.Write(code); } reader.Close(); writer.Flush(); writer.Close(); }
public void DecodeTest1() { Assert.AreEqual("HEY JUDE", MorseDecoder.Decode(".... . -.-- .--- ..- -.. .")); }
public void Setup() { morseDecoder = new MorseDecoder(); }
public static void Test_MessageWithStop() { string inputWithFullStop = "000000001101101100111000001111110001111110011111100000001110011111110001100111111000110011111100000001110111111110111011100000001100011111100000111111001111110000000110000110111111110111011100000011011100000000000"; Console.WriteLine(MorseDecoder.decodeBits2Morse(inputWithFullStop)); }
static void Main(string[] args) { //Morse // CodeWars web interface supplied an API for this dictionary InitializeDictionary(); string decodedString = MorseDecoder.Decoder(".... . -.-- .--- ..- -.. ."); Console.WriteLine(decodedString); //Tribonacci int n = 22; double[] tribo = new double[] { 0, 3, 16 }; double[] result = Tribonacci(tribo, n); foreach (var item in result) { Console.WriteLine(item); } //ValidatePin //string[] testCases = new string[] { "1234-+", "1234\n", "573012 ", "120412", "0000" }; bool resA = ValidatePin("1233-+"); bool resB = ValidatePin("1234\n"); bool resC = ValidatePin("573012 "); bool resD = ValidatePin("120412"); bool resE = ValidatePin("0000"); Console.WriteLine(resA); Console.WriteLine(resB); Console.WriteLine(resC); Console.WriteLine(resD); Console.WriteLine(resE); //Disemvowel string resultA = Disemvowel("This website is for losers LOL!"); string resultB = Disemvowel("Your mother is a terrible weight watcher LOL!"); Console.WriteLine(resultA); Console.WriteLine(resultB); //Exes and Ohs //(true, XO("xo")) //(true, XO("xxOo")) //(false, XO("xxxm")) //(false, XO("Oo")) //(false, XO("ooom")) var inputA = "xo"; var inputB = "xXOo"; var inputC = "xoomm"; bool resultBoolA = XO(inputA); bool resultBoolB = XO(inputB); bool resultBoolC = XO(inputC); Console.WriteLine(resultBoolA); Console.WriteLine(resultBoolB); Console.WriteLine(resultBoolC); // Sum Of Numbers(from A to B) int sumA = -1; int sumB = -5; int sum = GetSum(sumA, sumB); Console.WriteLine(sum); //Square Every Digit int squareMe = 9999; int squaredMe = SquareDigits(squareMe); Console.WriteLine(squaredMe); //DuplicateCount int duplicateCount = DuplicateCount("AaBbCc44a"); Console.WriteLine("Expected: 4 Count: " + duplicateCount); //ListFilterer //var list = new List<object>() { 1, 2, "a", "b" }; //var resultR = GetIntegersFromList(list); //foreach (var item in resultR) //{ // Console.WriteLine(item); //} //IQTest.. Console.WriteLine(Test("2 4 7 8 10")); //Number of people on the bus List <int[]> peopleListInOut = new List <int[]> { new[] { 10, 0 }, new[] { 3, 5 }, new[] { 5, 8 } }; int resultNumber = Number(peopleListInOut); Console.WriteLine(resultNumber); //WUBWUBWUBWUB string testAB = SongDecoder("WUBWUBABCWUB"); string testAC = SongDecoder("RWUBWUBWUBLWUB"); string testAD = SongDecoder("WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB"); Console.WriteLine(testAB); Console.WriteLine(testAC); Console.WriteLine(testAD); //NEWWORDORDER string inOrder = Order("is2 Thi1s T4est 3a"); Console.WriteLine(inOrder); //ArrayDiff int[] a = ArrayDiff(new int[] { 1, 2 }, new int[] { 1 }); int[] b = ArrayDiff(new int[] { 1, 2, 2, 2, 2 }, new int[] { 1 }); int[] c = ArrayDiff(new int[] { 1, 2, 2 }, new int[] { 2 }); int[] d = ArrayDiff(new int[] { 1, 2, 2 }, new int[] { }); int[] e = ArrayDiff(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 13, 14, 15 }, new int[] { 1, 7, 7 }); foreach (var item in b) { Console.WriteLine(item); } //Split String into pairs. if pairs are not even, even it out with "_" string[] resultSol = Solution("abcdedasdsdvsdfsfdada"); foreach (var item in resultSol) { Console.WriteLine(item); } }
public void DecodingACharacter() { Assert.AreEqual("e", MorseDecoder.Decode(".")); Assert.AreEqual("j", MorseDecoder.Decode(".---")); }
public void DecodingAWord() { Assert.AreEqual("steak", MorseDecoder.Decode("... - . .- -.-")); }
public void DecodingASentence() { Assert.AreEqual("i like steaks a lot", MorseDecoder.Decode(".. .-.. .. -.- . ... - . .- -.- ... .- .-.. --- -")); }
public void DecodeTest2() { Assert.AreEqual("HELLO WORLD", MorseDecoder.Decode(".... . .-.. .-.. --- .-- --- .-. .-.. -..")); }