Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's another approach, based on dmckee's work, demonstrating just how readable Python is:</p> <h1>Python</h1> <p>244 characters</p> <pre><code>def h(l):p=2*ord(l.upper())-88;a,n=map(ord,"AF__GF__]E\\E[EZEYEXEWEVEUETE__________CF__IBPDJDPBGAHDPC[DNBSDJCKDOBJBTCND`DKCQCHAHCZDSCLD??OD"[p:p+2]);return "--..--..-.-.-..--...----.....-----.-"[a-64:a+n-128] def e(s):return ' '.join(map(h,s)) </code></pre> <p>Limitations:</p> <ul> <li>dmckee's string missed the 'Y' character, and I was too lazy to add it. I think you'd just have to change the "??" part, and add a "-" at the end of the second string literal</li> <li>it doesn't put '/' between words; again, lazy</li> </ul> <p>Since the rules called for fewest <em>characters</em>, not fewest <em>bytes</em>, you could make at least one of my lookup tables smaller (by half) if you were willing to go outside the printable ASCII characters.</p> <p>EDIT: If I use naïvely-chosen Unicode chars but just keep them in escaped ASCII in the source file, it still gets a tad shorter because the decoder is simpler:</p> <h1>Python</h1> <p>240 characters</p> <pre><code>def h(l):a,n=divmod(ord(u'\x06_7_\xd0\xc9\xc2\xbb\xb4\xad\xa6\x9f\x98\x91_____\x14_AtJr2&lt;s\xc1d\x89IQdH\x8ff\xe4Pz9;\xba\x88X_f'[ord(l.upper())-44]),7);return "--..--..-.-.-..--...----.....-----.-"[a:a+n] def e(s):return ' '.join(map(h,s)) </code></pre> <p>I think it also makes the intent of the program much clearer.</p> <p>If you saved this as UTF-8, I believe the program would be down to 185 characters, making it the shortest complete Python solution, and second only to Perl. :-)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload