Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Luhn Number Golf

by PrakashK (Pilgrim)
on Feb 26, 2002 at 17:45 UTC ( #147662=note: print w/ replies, xml ) Need Help??


in reply to Luhn Number Golf

Here's a sub with 62 characters. Expects the number as an argument and returns 1 or 0.

sub luhn { #2345678901234567890123456789012345678901234567890123456789012 for(pop=~/(.)(.)/g){($a+=$1)+=$_ for map{split//}2*$2}!($a%10) }
/prakash


Comment on Re: Luhn Number Golf
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (19)
As of 2014-07-31 14:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (249 votes), past polls