DEV Community

Discussion on: Daily Challenge #23 - Morse Code Decoder

Collapse
 
choroba profile image
E. Choroba • Edited

Solved several years ago in a golf challenge. Perl (newlines added for readability):

@m{tc,cwt,ctct,cw,t,wct,et,ww,w,tec,ctc,tcw,e,ct,ec,tet,etc,
tct,wt,c,wc,wtc,te,cwc,cte,ew,eec,tee,wec,wte,wwc,wwt,cww,
ewt,ecw,eet}=(A..Z,0..9);s/- ?/c/g,s/\. ?/t/g,s/tt/w/g,
s/cc/e/g,s/(\S+) ? ?/$m{$1}/g,y/ //s,print for@ARGV