Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Morse Code JAPH

by davido (Archbishop)
on Aug 07, 2003 at 05:38 UTC ( #281754=obfuscated: print w/ replies, xml ) Need Help??

I don't know that this is terribly obfuscated, but at least you have to look at it twice to figure out what it's doing. It's my first JAPH, and my first attempt at obfuscation, so take that into consideration when evaluating its level of cleverness and obscurity. Someone reply when they figure out what and how. ;) And if you can improve upon it, I'd love to hear that too. This is a learning experience for me.

Based on a few suggestions I've further improved the code. Here it is in its present incarnation.

@qw{qw$.- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --.. .-.-.- | !$}=(A..Z ,q$.$,$",$/);print$qw{$_}for split/\s/,".--- ..- ... - | .- -. --- - .... . .-. | .--. . .-. .-.. | .... .- -.-. -.- . .-. .-.-.- !"

If you plan on cutting and pasting it, pay attention to whitespace in the word-wraps. All whitespace is significant.

By now everyone knows that this translates morse to alpha. Someone suggested only defining morse for those characters that I use, but in my opinion, that detracts from the code by, first, crippling the morse decoder; this one is full-fledged with respect to alpha; and second, depending on how far I go toward only defining translations for characters that I use, I would have to do away with the "A..Z" slice, which would lengthen the code and de-obfuscate it.

Someone else suggested constructing morse based on an algorithm, but to my knowledge, there is no predictable pattern to the morse alphabet. Numbers are somewhat more predictable.

Finally, thank-you to those who offered tips toward reaching this most recent version. It's been a fun learning experience. Hopefully it provokes thought in others reading this thread. If you see other areas for improvement, I'd love to hear; the process never ends.

"If I had my life to do over again, I'd be a plumber." -- Albert Einstine

Comment on Morse Code JAPH
Download Code
Replies are listed 'Best First'.
Re: Another JAPH
by OverlordQ (Hermit) on Aug 07, 2003 at 06:14 UTC
    Looks to be morse code:
    perl -e 'my %rt; @rt{qw/.- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --.. .-.-.- | !/}=("A".."Z","."," ","\n");
    hashes the dots and dashes to the letters, comma, and period.
    for(split /\s+/,".--- ..- ... - | .- -. --- - .... . .-. | .--. .  .-. .-.. | .... .- -.-. -.- . .-. .-.-.- !"){print $rt{$_};}'

    THen feeds your dots/dashes space delimited one by one as keys to the hash whereby the print prints out the letter.
Re: Another JAPH
by mildside (Friar) on Aug 07, 2003 at 06:14 UTC
    Uses a 'morse-code to alpha' hash as a lookup. Neato!


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: obfuscated [id://281754]
Approved by sschneid
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2015-11-29 14:36 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (751 votes), past polls