Quote:

Hey Eric, would you mind explaining how you coded around these tests?

3456789012345675=0 valid luhn but 16 digits
456789012345671=0 valid luhn but 15 digits
567890123456781=0 ""
678901234567899=0 ""

Edit...actually maybe its just a valid Amkixpress I would be interested in.


I set $a to 0 by default. And then the if statement decides whether I even try to process string.

 Code:
if $>3 & $<7 & len($)+($<4)=16


the first condition ensures that string doesn't start with 0-2. The second condition makes sure it doesn't start with 7-9.

And the last condition makes sure that the length is 16 characters...but we need to add one if it starts with a 3. Since we are already discard 0-2, we can just check that it's less than 4 instead of exactly 3, so that condition will add 1 when appropriate.

So if starts with a 3 and isn't 15 characters long, we never drop into the loop.

Nice code Drill!! Definitely similar to mine, but you're golfing skillz are impressive! \:\)
_________________________
Eric