Search results
Results From The WOW.Com Content Network
The algorithm. You'll need to start with the binary tree parsed in preorder, find the index of the letter you want to encode to morse, convert that to binary, ignore the first digit, and then just assign the zeros to dots, and the ones to dashes. It's really simple. A C implementation example.
I have an assignment that requires me to decode a Morse code string. The assignment specifies that: - There will be no space between a character (example between . and -) - Each character is separated by 1 space - Each word is separated by 4 space. So far I have:
So I have an assignment where I have to create a program that translates English text into morse code, and morse code to english text. So far I have done the English text to morse code and I am currently stuck on morse code to english text.
I'm trying to write a program where the morse code of the given text by the system is required. About the converting text to morse code, I wrote them all in main (separately from the program file itself). And now, my aim is to write it as a function in order to use it in the other functions of the program.
before you write a dictionary with the same values use var morseToAscii = morse.ToDictionary(item => new KeyValuePair<string, string>(item.Value.Trim(), item.Key)); to just copy it with keys and values flipped. cause you used a space as seperator for the morse code just use morseInput.Split(' ') to get an array with all input chars.
I have two text files to use with this problem. morseCode.txt: I have a file that i read off that contains the letters and corresponding Morse code equivalent. morse.dat: Its the file that contains the encrypted message in Morse code. I was able to read the first file properly and then store then into separate arrays. I tested it by printing ...
In order to loop over the dictionary of the morse code (an object) you can convert it into array by Object.keys etc and then find the specific letter (in morse) in the converted array (search the specific key). an example of morse code: decodeMorse('.... . -.-- .--- ..- -.. .'); //should return:"HEY JUDE" the function:
I know this is an old question but in the tradition of open source I wrote code to implement the fact that Morse is a binary tree and this may be faster than using a dictionary: class node: def __init__(self, char): self.dot = None. self.dash = None. self.alpha = char. def __str__(self): return self.alpha. def nextNode(self, basenode, char):
The instruction for the user is to leave a blank space between morse code letters, and three blank spaces between morse code words. The problem is, when I type in for example ".-", which is supposed to be A in text , the output would be E and T which are "." and "-". How to differentiate between morse codes, since they are only using "-" and "."?
The way your code exists currently, you are stepping through the input (correct), but for each character in the input, you're not fetching the equivalent in Morse Code! You're instead comparing the entire input to the single English character at english[index] .