-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmorse_code.cpp
35 lines (29 loc) · 989 Bytes
/
morse_code.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <unordered_map>
#include <string>
#include <vector>
#include <unordered_set>
int main()
{
std::unordered_map<char, std::string> morseCodeMap = {
{'a', ".-"}, {'b', "-..."}, {'c', "-.-."}, {'d', "-.."}, {'e', "."},
{'f', "..-."}, {'g', "--."}, {'h', "...."}, {'i', ".."}, {'j', ".---"},
{'k', "-.-"}, {'l', ".-.."}, {'m', "--"}, {'n', "-."}, {'o', "---"},
{'p', ".--."}, {'q', "--.-"}, {'r', ".-."}, {'s', "..."}, {'t', "-"},
{'u', "..-"}, {'v', "...-"}, {'w', ".--"}, {'x', "-..-"}, {'y', "-.--"},
{'z', "--.."}
};
std::vector <std::string> words = {"gin","zen","gig","msg"};
std::string strs;
std::unordered_set <std::string> ans;
if(!words.empty()){
for(std::string word : words){
strs = "";
for(char c : word){
strs = strs + morseCodeMap[c];
}
}
}
std::cout << ans.size();
return 0;
}