Skip to content

Commit

Permalink
Merge pull request #291 from behrtam/fix-lambda-luhn
Browse files Browse the repository at this point in the history
luhn: fix lambda usage (see #287)
  • Loading branch information
behrtam committed Jan 26, 2016
2 parents b0f9c50 + c31cf1f commit 096a07f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion luhn/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ def __init__(self, number):
self.number = number

def addends(self):
def luhn_transform(n):
return (2 * n - 9) if (n > 4) else (2 * n)
old_digits = [int(d) for d in str(self.number)]
luhn_transform = lambda n: (2 * n - 9) if (n > 4) else (2 * n)
return [(luhn_transform(n) if (i % 2 == 0) else n)
for i, n in enumerate(old_digits, start=len(old_digits) % 2)]

Expand Down

0 comments on commit 096a07f

Please sign in to comment.