Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Straightforward solution in Uncategorized category for CheckSum by nickie
interesting = lambda c: c.isdigit() or c.isupper()
number = lambda c: ord(c)-48
double = lambda n: sum(int(d) for d in str(2*n))
def checkio(data):
s = sum(double(n) if i % 2 == 0 else n
for i, n in enumerate(number(c)
for c in reversed(data)
if interesting(c)))
return [str((-s)%10), s]
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert (checkio("799 273 9871") == ["3", 67]), "First Test"
assert (checkio("139-MT") == ["8", 52]), "Second Test"
assert (checkio("123") == ["0", 10]), "Test for zero"
assert (checkio("999_999") == ["6", 54]), "Third Test"
assert (checkio("+61 820 9231 55") == ["3", 37]), "Fourth Test"
assert (checkio("VQ/WEWF/NY/8U") == ["9", 201]), "Fifth Test"
print("OK, done!")
Feb. 14, 2014