# Encoding Morse Code

The letters of a message are converted to Morse code, with a space between each pair of letters and two spaces between each pair of words. Each pair of elements (for example dot-space, dash-dash, and so on) is then assigned a number from 1 to 9. A message written in this system is as follows:

512537293228231463737325742346428147

What pair of elements corresponds to each number, and what does the message say?

Hint 1:

Start by analysing 2282 .

• Arrgh, the no-computers tag! – Wen1now Mar 7 '17 at 7:58
• It is meant to be a space between pairs of letters and not between letter right? – Wen1now Mar 7 '17 at 10:05
• I think it's meant to be .-../../-.-/.//.../--- without spaces (/) at the beginning or at the end of the phrase. – M Oehm Mar 7 '17 at 10:17
• Is this even possible to solve without brute-force or guesswork? – Techidiot Mar 7 '17 at 11:22
• @humn: Yes, that's what I'm suggesting and I had hoped that the OP would address it. After trying for quite a while, I threw a program at it and it came up with rot13(JRYV ORTHA VFUNYS QBAR), which has two obvious typos. The pairwise Morse code for the corrected sentence is quite different, because the typo in the fourth characer introduces a parity mismatch. And I don't see how 2282 helps in deciphering. The alternating chain 37373 seems more promising. I didn't post an answer, because I used a program. – M Oehm Mar 23 '17 at 16:50

## 1 Answer

The secret message and digit correspondences are . . .

    W   E   L   L       B  E  G   U  N     I S       H   A   L   F       D  O  N  E
.-- . .-.. .-.. / -... . --. ..- -. / .. ... / .... .- .-.. ..-. / -.. --- -. .

.--/./.-../.-..//-..././--./..-/-.//../...//..../.-/.-../..-.//-../---/-././
5 1 2 5 3 7 4 2 9 3 2 2 8 2 3 1 4 6 3 7 3 6 3 3 7 1 5 3 7 5 2 9 3 9 8 9 2 2

-/   ./   ..   -.   .-   //   /.   --   /-

1    2    3    4    5    6    7    8    9    

This puzzle is built on a superb premise.   Morse code’s natural 9 dot /dash /space pairs may be recoded as digits for a perfect combination of encryption and clue-idity.   Morse code’s statistical skew provides a nicely shaped search space, like slopes and valleys that concentrate hunches.

The puzzle needed minor rebuilding.   Unfortunately the original encryption contained imperfections.   Fortunately M Oehm figured out (!) the intended message computationally.   Unfortunately that message’s encryption has an odd number of dots /dashes /spaces, so the rules need to say that the message ends with a space.

Revised encryption and rules.   The 38 digits of 51253742932282314637363371537529398922 represent a combination of 76 dots, dashes and spaces.   Every Morse code letter is followed by a space while an additional space separates each pair of words.   For example, Morse code for LIKE THIS would be .-../../-.-/.//-/..../../.../, where each / represents a space.

Solution begins by doubling the encoded digits and profiling a statistically likely solution.

       5511225533774422993322228822331144663377336633337711553377552299339988992222

-/-/-/././/../../../-./.-/-.//.../.-./-../---/---//..--/..-./.-../.-../-..-/



The -/-/-/ . . . /-..-/ profile has approximately 5 letters per word, approximately equal counts of letter lengths, and favors . over - as is statistically expected.   Here is the distribution of code digits and, without elaboration, likelihoods of their counts if they were specific dot /dash /space pairs.

               Pair:           ..    -.    .-    --    ./    /.    /-    -/    //

Expected:        5.5    4    3.5   2.5   6.5    6     4     4    1.5

Actual code digits                      Probabilities
3 3 3 3 3 3 3 3 3    .05   .01   .005  .0005 .09   .07   .01   .01   .00001
(last)    2 2 2 2 2 2 2 2     .09   .03   .01   .002  .13   .11   .03   .03   .00008
(first)       5 5 5 5         .16   .21   .14   .07   .11   .13   .21   .21   .05
7 7 7 7         .16   .21   .14   .07   .11   .13   .21   .21   .05
9 9 9 9         .16   .21   .14   .07   .11   .13   .21   .21   .05
1 1 1          .11   .20   .22   .22   .06   .08   .20   .20   .13
4 4           .05   .14   .18   .26   .02   .04   .14   .14   .26
6 6           .05   .14   .18   .26   .02   .04   .14   .14   .26
8 8           .05   .14   .18   .26   .02   .04   .14   .14   .26


Morse code within-word statistics.   Strongly skewed in favor of dots.   (Derived from Wikipedia)


Frequencies of pairs:      ..  15.9%       -.  10.5%       /.  17.1%       ./  18.0%
.-   9.7%       --   7.4%       /-  11.1%       -/  10.3%

Letters grouped by beginnings           Letters grouped by endings        Total by length
----------------------------------    ----------------------------------    ---------------
E  /.    12.7%    T  /-     9.1%      E     ./ 12.7%    T     -/  9.1%        1   21.8%

A  /.-    8.2%    M  /--    2.4%      I    ../  7.0%    A    .-/  8.2%        2   24.3%
I  /..    7.0%    N  /-.    6.7%      N    -./  6.7%    M    --/  2.4%

R  /.-.   6.0%    D  /-..   4.3%      D   -../  4.3%    K   -.-/  0.8%        3   32.0%
S  /...   6.3%    G  /--.   2.0%      G   --./  2.0%    O   ---/  7.5%
U  /..-   2.8%    K  /-.-   0.8%      R   .-./  6.0%    U   ..-/  2.8%
W  /.--   2.4%    O  /---   7.5%      S   .../  6.3%    W   .--/  2.4%

F  /..-.  2.2%    B  /-...  1.5%      B  -.../  1.5%    J  .---/  0.2%        4   22.0%
H  /....  6.1%    C  /-.-.  2.8%      C  -.-./  2.8%    Q  --.-/  0.1%
J  /.---  0.2%    Q  /--.-  0.1%      F  ..-./  2.2%    V  ...-/  1.0%
L  /.-..  4.0%    X  /-..-  0.1%      H  ..../  6.1%    Y  -.--/  2.0%
P  /.--.  1.9%    Y  /-.--  2.0%      L  .-../  4.0%    X  -..-/  0.1%
V  /...-  1.0%    Z  /--..  0.1%      P  .--./  1.9%
Z  --../  0.1%
-------           -------              -------          -------
/.   60.7%        /-   39.3%          ./    63.6%       -/   36.4%


Solution proceeds by testing most-likely matches.   The clear place to begin is with the 22 at the end. Not only must it end with a / space, but it is also so numerous that the most-likely-of-all ./ pair is the best candidate.

code
|
|  substitution
|  |
|  |  5511225533774422993322228822331144663377336633337711553377552299339988992222
2 ./  5511./55337744./9933././88./33114466337733663333771155337755./9933998899././
|                     e                                                   e
result


The next code to assign is the most-numerous 3, and the statistically favored candidate is /.

      5511225533774422993322228822331144663377336633337711553377552299339988992222
2 ./  5511./55337744./9933././88./33114466337733663333771155337755./9933998899././
3 /.  5511./55/.7744./99/.././88.//.114466/.77/.66/./.771155/.7755./99/.998899././
^^ i  e ^^ //                                     ^^^^^^

998899     means that 88 or 99 must contain a / space.
/i/e/88.//   prevents anything meaningful if 88 contains a / space.
/99/i/e     prevents 99 from being // or -/
So the next assignment to try is  9  =  /-    ( ./ and /. are already taken)

5511225533774422993322228822331144663377336633337711553377552299339988992222
2 ./  5511./55337744./9933././88./33114466337733663333771155337755./9933998899././
3 /.  5511./55/.7744./99/.././88.//.114466/.77/.66/./.771155/.7755./99/.998899././
9 /-  5511./55/.7744.//-/.././88.//.114466/.77/.66/./.771155/.7755.//-/./-88/-././
//t e     n  e
//t/-88/n/e  cannot be a word.                                     ^^^^^^^^^^^^^^


So much for 3 being /..   The next most likely candidate for 3 is ...

       5511225533774422993322228822331144663377336633337711553377552299339988992222
2 ./  5511./55337744./9933././88./33114466337733663333771155337755./9933998899././
3 ..  5511./55..7744./99..././88./..114466..77..66....771155..7755./99..998899././
^^^^^^^  ^^^ e
/99..99     means that 99 must contain a / space.
99./e/     makes /- the most likely candidate for 99.  ("ne" vs. "ee" or "ie")

5511225533774422993322228822331144663377336633337711553377552299339988992222
2 ./  5511./55337744./9933././88./33114466337733663333771155337755./9933998899././
3 ..  5511./55..7744./99..././88./..114466..77..66....771155..7755./99..998899././
9 /-  5511./55..7744.//-..././88./..114466..77..66....771155..7755.//-../-88/-././
//  b  e                      h               // d  ^^^ n  e

From here the solution unravels neatly enough without further narrative.

8 --  5511./55..7744.//-..././--./..114466..77..66....771155..7755.//-../---/-././
//  b  e  g            ^^     h  ^^      ^^   // d   o  n  e

7 /.  5511./55../.44.//-..././--./..114466../...66..../.1155../.55.//-../---/-././
//  b  e  g                ^^ h               // d   o  n  e

6 //  5511./55../.44.//-..././--./..1144//../...//..../.1155../.55.//-../---/-././
//  b  e  g        // i  s // h    ^^^^    ^^ // d   o  n  e

1 -/  55-/./55../.44.//-..././--./..-/44//../...//..../.-/55../.55.//-../---/-././
e          //  b  e  g   u  ^^// i  s // h   a           // d   o  n  e

4 -.  55-/./55../.-..//-..././--./..-/-.//../...//..../.-/55../.55.//-../---/-././
5 .-  .--/./.-../.-..//-..././--./..-/-.//../...//..../.-/.-../..-.//-../---/-././
w  e  l    l  //  b  e  g   u  n // i  s // h   a   l    f  // d   o  n  e   

So how did the actual statistics compare to predictions?   Very well!   Only two digits, representing .. and -., varied much from expectation and created just one false lead.

                   Pair     Predicted              Actual
Digits          Morse
./         17%        8    21%       15    20%
/.         16%        4    11%       12    16%
..         15%        9    24%       14    19%
/-         11%        4    11%        6     8%
-.         11%        2     5%        9    12%
-/         11%        3     8%        4     5%
.-          9%        4    11%        7     9%
--          7%        2     5%        4     5%
//          4%        2     5%        4     5%

• Amazing answer @humn! Great solve. – Techidiot Mar 31 '17 at 11:00
• The mechanics of the puzzle were too good to let go, puzzler @Techidiot, for weeks. I want to plagiarize it. – humn Mar 31 '17 at 11:08