Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for CheckSum by chunshar
def checkio(data):
res = sum(sum(divmod(n * 2, 10)) if i % 2 == 0 else n
for i, n in enumerate(ord(c) - 48 for c in reversed(data) if c.isalnum()))
final = str(10 * (res % 10 != 0) - (res % 10))
return [final, res]
#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!")
Nov. 10, 2018