Perl GolfUpdate: To get it started, here is my first attempt.... 61 charsWe 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.
#!/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
In reply to Fore!!! (was The Perl Review)
by blakem
in thread The Perl Review
by Kit
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |