Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Luhn Number Golfby Cody Pendant (Prior) |
on Feb 26, 2002 at 11:26 UTC ( [id://147528]=perlmeditation: print w/replies, xml ) | Need Help?? |
I was just looking at the about.com Perl site, and it has this article about finding if a number is a valid Luhn number, which, apparently, tells you it's a valid credit card number.
If what you've got is divisible by ten, it's a valid credit card number. Their solution is at http://perl.about.com/library/weekly/aa080600h.htm, and of course it's quite long, because it's a teaching exercise. I got thinking about it and how to do it more compactly, in the spirit of "Regular Expressions -- is there anything they can't do?" and tried to make it as short as I could. Here's an attempt, but I'd love to see you make it shorter:
Back to
Meditations
|
|