Looks like a great contender to replace the downtrodden TPJ. Anyone interested in the golf-master position detailed below?
Perl Golf
We have not figured out the rules, chosen the judges,
or calculated what your chances of winning really are,
but we do have the prizes – Perl Mongers hats or tshirts
along with a chance for fame and glory in the
next issue of The Perl Review.
Solve the following problem with a ridiculously low
number of keystrokes, uses Perl in some clever or devious
way, or is otherwise interesting and send it to
comdog@panix.com.
Convert a base 36 number, with the
digits [0-9A-Z], to its base 10 representation
If you would like to be a judge, or the maintainer of
this column, or have an interesting golf problem, let
us know. We can send you a hat or a t-shirt too.
Update: To get it started, here is my first attempt.... 61 chars
#!/usr/bin/perl -wT
use strict;
my $base36 = shift;
$base36 = 10 if !defined $base36;
die "invalid input, only 0-9 and A-Z allowed\n"
if $base36 !~ /^[0-9A-Z]+\z/;
my $dec = base36($base36);
print "$base36 => $dec\n";
sub base36 {
# 1 2 3 4 5 6
#234567890123456789012345678901234567890123456789012345678901
$%+=$_*36**$?++for reverse map/\d/?$_:ord($_)-55,pop=~/./g;$%
}
-Blake
-
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.
|