Luhn test for credit card numbers

Implements the Luhn test succinctly.


This solution was chosen as I had to factor the convoluted wikipedia description to find a better way to calculate the answer. I prefer this description, posted on Rosetta Code.

def luhn(n):
    r = [int(ch) for ch in str(n)][::-1]
    return (sum(r[0::2]) + sum(sum(divmod(d*2,10)) for d in r[1::2])) % 10 == 0

code.activestate.com ↗