Skip to main content
5 of 6
Rewrote the code. Remembered the `vec` function which is very useful here.
Kjetil S
  • 6.1k
  • 10
  • 22

Perl 5, 283 244 bytes

$s=<>;$s=~s/..{$_}//+print$s=~/(.) \Q$& / for map{vec unpack('u',q{MJZDYEM98;HWE31N4>Y9:6'Y,BZYRSZ1<JI2@]ZH_(Z8H)7@V[G5*V2NC&:NZM3':XVCLCHY2@(IY>WE\5,L<XK*K^6U5+"5K(9*S^)B5CT07:JK_Q:HINCL:J=23LYEL.T,E*".U[)[`HJQ@ZJ/R.F*"6XOJK5B0X`}),$_,2}0..473

Try it online!

This corresponds to:

$L = <<'';                            # length bits in base64
MJZDYEM98;HWE31N4>Y9:6'Y,BZYRSZ1<JI2@]ZH_(Z8H)7@V[G5*V2NC&:NZM3':XVCLCHY2@(IY>WE\5,L<XK*K^6U5+"5K(9*S^)B5CT07:JK_Q:HINCL:J=23LYEL.T,E*".U[)[`HJQ@ZJ/R.F*"6XOJK5B0X`

$s = <>;                              # read inputs
$s =~ s/..{$_}//                      # take current length morse code from start
  + print $s=~/(.) \Q$& /             # ...and print corresponding letter
  for map vec(unpack('u',$L), $_, 2), # find morse code lengths of the letters
      0..473                          # 474 letters

This could perhaps be further shortened by encoding in base128 or directly in "base256". Huffman encoding the lengths could shorten the length data, but most probably enlarge the rest of the code.

Kjetil S
  • 6.1k
  • 10
  • 22