Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for CheckSum by Rounin
import re
def checkio(data):
data = list(map(lambda n: ord(n) - 48, list(re.sub('[^A-Z0-9]','', data.upper())[::-1])))
summ = 0
for i in range(len(data)):
summ += (data[i] if i&1 == 1 else sum(map(int, list(str(data[i]*2)))))
return [str((10-(summ%10))%10), summ]
#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!")
Aug. 5, 2017