Goal
Morse code is often represented as sound. Given a stream of bits that represent whether sound is on or off, translate the stream into letters and numbers and spaces.
Specifics
- The bit stream is analysed based on the length of repeating ON/OFF bits.
- 1 ON bit is a dot
- 3 ON bits are a dash
- 1 OFF bit delimits dots and dashes
- 3 OFF bits delimits characters
- 7 OFF bits delimits words (space)
- The input may be a string or array. Only two unique characters/values of your choice are allowed in the input. (eg. 0/1, true/false, comma/space)
- The output returns a string or is printed to the standard output.
Example
Input: 101010100010001011101010001011101010001110111011100000001011101110001110111011100010111010001011101010001110101
Analysis: \--H--/ E \---L---/ \---L---/ \----O----/\-- --/\---W---/ \----O----/ \--R--/ \---L---/ \--D--/
Output: HELLO WORLD
Assumptions
- The stream always starts and ends with an ON bit.
- There is no leading or trailing whitespace.
- The input is always valid.
- All letters (case-insensitive) and digits are supported.
Test Cases
101010100010001011101010001011101010001110111011100000001011101110001110111011100010111010001011101010001110101
HELLO WORLD
10100000001011100011101110000000101110000000101011101000101000101010001010101
I AM A FISH
1010111011101110001110111011101110111000101110111011101110001110111010101
2017
101010001110111011100010101
SOS
Scoring
This is code golf. The lowest byte-count code by this time next week wins.