Decode Ambiguous Morse Messages
Company: Sealth
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates string parsing, pattern matching, and combinatorial decoding skills using a Morse-to-letter mapping, covering both deterministic separator handling and enumeration of ambiguous letter partitions.
Decode Morse With Separators
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ('.... . .-.. .-.. --- / .-- --- .-. .-.. -..', ' ', ' / ', {'....':'h','.':'e','.-..':'l','---':'o','.--':'w','.-.':'r','-..':'d'})
Expected Output: 'hello world'
Explanation: Decode with explicit character and word separators.
Hints
- Clarify edge cases before coding.
- Keep the return value deterministic.
Enumerate Morse Decodings Without Character Separators
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ('....../.-', '/', {'.':'e','-':'t','....':'h','..':'i','...':'s','.-':'a'})
Expected Output: ['eeeeee a', 'eeeeee et', 'eeeei a', 'eeeei et', 'eeeie a', 'eeeie et', 'eees a', 'eees et', 'eeh a', 'eeh et', 'eeiee a', 'eeiee et', 'eeii a', 'eeii et', 'eese a', 'eese et', 'ehe a', 'ehe et', 'eieee a', 'eieee et', 'eiei a', 'eiei et', 'eiie a', 'eiie et', 'eis a', 'eis et', 'esee a', 'esee et', 'esi a', 'esi et', 'hee a', 'hee et', 'hi a', 'hi et', 'ieeee a', 'ieeee et', 'ieei a', 'ieei et', 'ieie a', 'ieie et', 'ies a', 'ies et', 'ih a', 'ih et', 'iiee a', 'iiee et', 'iii a', 'iii et', 'ise a', 'ise et', 'seee a', 'seee et', 'sei a', 'sei et', 'sie a', 'sie et', 'ss a', 'ss et']
Explanation: Enumerate all decodings for each separator-delimited word.
Input: ('', '/', {'.':'e'})
Expected Output: ['']
Explanation: Empty encoded input has one empty sentence.
Hints
- Clarify edge cases before coding.
- Keep the return value deterministic.