Thanks Grimy.
By the way, the PHP md5 solution works in Perl too
since these two languages have essentially the same
bitwise string operators:
use Digest::MD5 qw(md5_hex);
sub r {uppp&md5_hex$_.PQcUv}
print "$_: ", 0+r(), "\n" for (qw(I V X L C D M));
I've updated the Perl summary of shortest solutions in the root node like so:
VLD=~$_*5+IXCM=~$_."E@-" # Perl
10**(7&5045e8/ord)%2857 # Perl (64-bit)
IXCMVLD=~$_;"1E@-"%9995 # Perl
XCMVLD=~$_;"1E@+"%9995 # Perl (Grimy improvement)
uppp&md5_hex$_.PQcUv # Perl (needs Digest::MD5 module)
As you can see, if Perl had a md5 built-in function, this would be
the shortest Perl solution --
even with a ridiculously long md5_hex function name!
Update: for full details on how I happened to find this md5 solution, see Re^2: The golf course looks great, my swing feels good, I like my chances (Part III).
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|