morse-code

Decode Morse without white spaces to text

廉价感情. 提交于 2021-02-18 12:57:54
问题 Is there any possibility to decode Morse code to text if the code is in following format(without any white spaces): -.-..--.....-...--..----. Normally it looks like that, - .-. .- -. ... .-.. .- - .. --- -. t r a n s l a t i o n but is it possible, to get the same text from Morse code without white spaces? 回答1: This is possible to do, but it becomes problematic as you end up generating a large number of possible options. First start with a Morse mapping: private Dictionary<string, string> map

C++ weird for loop syntax [duplicate]

ε祈祈猫儿з 提交于 2021-02-05 12:36:55
问题 This question already has answers here : 'colon' and 'auto' in for loop c++? need some help understanding the syntax (3 answers) Closed 3 years ago . std::string decodeMorse(std::string morseCode) { // ToDo: Accept dots, dashes and spaces, return human-readable message std::string decoded; for( auto p : morseCode ) { if( p == '.' ) decoded += MORSE_CODE[ "." ]; else if( p == '-' ) decoded += MORSE_CODE[ "-" ]; } return decoded; } This is a code extract from https://www.codewars.com Can

C++ weird for loop syntax [duplicate]

╄→尐↘猪︶ㄣ 提交于 2021-02-05 12:34:33
问题 This question already has answers here : 'colon' and 'auto' in for loop c++? need some help understanding the syntax (3 answers) Closed 3 years ago . std::string decodeMorse(std::string morseCode) { // ToDo: Accept dots, dashes and spaces, return human-readable message std::string decoded; for( auto p : morseCode ) { if( p == '.' ) decoded += MORSE_CODE[ "." ]; else if( p == '-' ) decoded += MORSE_CODE[ "-" ]; } return decoded; } This is a code extract from https://www.codewars.com Can

python text to morse translator breaks in mid-way

二次信任 提交于 2021-01-05 07:20:15
问题 As a practice in python, I tried to make a text to morse translator. but it breaks after executing only once. Could you help me figure out the problem? (It's probably in morse function) function beep is for sound, dictionary item_list is a pack of every character's special code. import winsound import time def beep(char): if char == 'a': winsound.Beep(500, 150) time.sleep(150) winsound.Beep(500, 500) time.sleep(150) elif char == 'b': winsound.Beep(500, 500) time.sleep(150) winsound.Beep(500,

python text to morse translator breaks in mid-way

丶灬走出姿态 提交于 2021-01-05 07:18:24
问题 As a practice in python, I tried to make a text to morse translator. but it breaks after executing only once. Could you help me figure out the problem? (It's probably in morse function) function beep is for sound, dictionary item_list is a pack of every character's special code. import winsound import time def beep(char): if char == 'a': winsound.Beep(500, 150) time.sleep(150) winsound.Beep(500, 500) time.sleep(150) elif char == 'b': winsound.Beep(500, 500) time.sleep(150) winsound.Beep(500,

Parsing morse code

戏子无情 提交于 2020-03-04 06:13:48
问题 I am trying to solve this problem. The goal is to determine the number of ways a morse string can be interpreted, given a dictionary of word. What I did is that I first "translated" words from my dictionary into morse. Then, I used a naive algorithm, searching for all the ways it can be interpreted recursively. #include <iostream> #include <vector> #include <map> #include <string> #include <iterator> using namespace std; string morse_string; int morse_string_size; map<char, string> morse

Morse Code via iPhone LED

霸气de小男生 提交于 2020-01-11 11:32:46
问题 I have coded an App that can convert normal Text like : "Hello my Name is XY" into points and strokes ( ..-. ; --.- ; . ; - ; etc etc) Now I want to Convert these points and stroke into light flashes with the lenght of 0.3 sec for points an 0.6 seconds for strokes. also there is a pause with the length of a point after each point or stroke, a double pause after each Word, and a tripple pause/break after each sentences. The breaks are also implied into my code. The problem is now that the

Morse Code via iPhone LED

眉间皱痕 提交于 2020-01-11 11:32:46
问题 I have coded an App that can convert normal Text like : "Hello my Name is XY" into points and strokes ( ..-. ; --.- ; . ; - ; etc etc) Now I want to Convert these points and stroke into light flashes with the lenght of 0.3 sec for points an 0.6 seconds for strokes. also there is a pause with the length of a point after each point or stroke, a double pause after each Word, and a tripple pause/break after each sentences. The breaks are also implied into my code. The problem is now that the

Translate morse code into alphabets

浪尽此生 提交于 2019-12-25 01:48:54
问题 I am working on a project that could translate morse code into english and vice versa. The below is the specific instruction: "Your program shall prompt the user to specify the desired type of translation, input a string of Morse Code characters or English characters, then display the translated results. When inputting Morse Code, separate each letter/digit with a single space, and delimit multiple words with a “|”. For example, - --- | -... . would be the Morse Code input for the sentence

Can I access the English dictionary to loop through matches in morse code? If not can I copy and paste it from some place onto just afew lines?

强颜欢笑 提交于 2019-12-21 20:03:31
问题 So I am writing a program in python 2.7 that loops through all of the words in the English to see if the Morse code version of English word matches the unknown Morse phrase. The reason I can't just interpret it is because there are no spaces between letters. This is a snippet of the code: def morse_solver(nol,morse,words): #nol is the number of letters to cut down search time,morse is the Morse phrase to decode, and words is a string (or can be a list) of all english words. lista=_index(words