Ctrl K

Distinct Morse Signals

Easy
A radio operator sends words in Morse code. The codes for the letters a to z, in order: [".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."] A word is sent as its letters' codes glued together with no pauses, e.g. "cab" → -.-. + .- + -... = -.-..--.... So different words may sound the same. Given a list words, how many distinct signals come out when every word is sent?
Example 1
words=["et", "n", "a"] → 2

"et" → . + - = .-, the same as "a". "n" → -.. Two distinct signals.

Example 2
words=["sos", "help"] → 2

The signals ...---... and .....-...--. differ.

Constraints
  • 1 ≤ len(words) ≤ 100
  • 1 ≤ len(words[i]) ≤ 12
  • Words consist of lowercase English letters
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsOne-Row Typing EasyDinner for Two EasyPhrases with Synonyms EasyWord from a License Plate EasyReal Inboxes Behind the Addresses Easy
loading Python…
Input
words=["et", "n", "a"]
Expected
2

Run checks the first 3 tests in your browser. Submit checks all 59 tests on the server, hidden ones included.