Daniel Martin <martin / snowplow.org> writes:

> Just one minor nit:
>
> Christian Neukirchen <chneukirchen / gmail.com> writes:
>
>> def luhn?(n)
>>   f = 2
>>   (n.delete("^0-9").reverse.split(//).map{|d|d.to_i}.
>>      inject(0) { |a,e| f=3-f; a + (e*f > 9 ? e*f-9 : e*f) } % 10).zero?
>> end
>
> You do know that (e*f > 9 ? e*f-9 : e*f) is equivalent to e*f%9,
> right?  So that makes this method:

I first thought that too, and it cost me 10min to find that 9%9 == 0.

-- 
Christian Neukirchen  <chneukirchen / gmail.com>  http://chneukirchen.org