adamcrussell

Perl Weekly Challenge 035

This week's challenge was to encode/decode binary morse code.

ch-1.pl
ch-1.pl


ch-2.pl
ch-2.pl

Sample Run

$ perl perl5/ch-1.pl PWC
1011101110100010111011100011101011101

$ perl perl5/ch-2.pl 1011101110100010111011100011101011101
PWC 

Notes

  • Both parts use much of the same logic: split on gaps and map!
  • In both we start with the same hash but in Part 2 we use the reverse, in order to look up letters by their morse value.
  • I can't recall ever having used join so many times in any one script before. The usage here seems appropriate in that we are making a lot of use of arrays but then need to merge their elements into a single string.

Comments for this post were locked by the author