Ternary Pulse Decoder
Preview mode. Log in to edit, run, submit, and save progress.
Ternary Pulse Decoder
A telemetry decoder receives a compressed stream made of dots and dashes. A single dot represents digit 0. A dash followed immediately by a dot represents digit 1. Any dash that is not followed by a dot represents digit 2; if another dash follows it, that next dash is consumed as part of the same token. Decode each stream into its digit sequence. Input Format: The first line contains t, the number of test cases. Each test case contains one valid dot-dash stream. Output Format: For each test case, print the decoded digit string.
Examples
1 .--
02
Explanation: The stream splits into '.' and '--', which decode to 0 and 2.
Approach hint
Start with the simplest clear approach, explain the trade-off, then move toward the cleaner answer.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.