Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Base36 numbers: speed and golf

by Ido (Hermit)
on Feb 27, 2002 at 20:16 UTC ( [id://148019]=note: print w/replies, xml ) Need Help??


in reply to Base36 numbers: speed and golf

It's ugly, not golfy, and not fast, but that's the best I could come up with:
my $number="8i8jkwdz4fks4d1z"; chg(1); sub chg{(substr($number,-1*$_[0],1)=dig(substr($number,-1*$_[0],1))) e +q '0' and chg($_[0]+1)} sub dig{my $d=shift; if($d==9){return 'a'}elsif($d=~/\d/){return $d+1} +elsif(lc($d) eq 'z'){return 0}else{return chr(ord($d)+1)}} print $number;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://148019]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-03-29 08:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found