Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for CheckSum by UFO665
# migrated from python 2.7
from string import ascii_uppercase, digits
lstIntMapPoint = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]
dctAlphanumMapPoint = {c: sum(int(c) for c in repr((ord(c) - 48) * 2)) for c in ascii_uppercase + digits}
def checkio(data):
data = "".join(c for c in data[::-1] if c.isalnum())
if data.isdigit():
lstDigits = [int(c) if i % 2 else lstIntMapPoint[int(c)] for i, c in enumerate(data)]
else:
lstDigits = [ord(c) - 48 if i % 2 else dctAlphanumMapPoint[c] for i, c in enumerate(data)]
sFinalChar = repr(10 - sum(lstDigits) % 10)
return [sFinalChar if sFinalChar != "10" else "0", sum(lstDigits)]
Feb. 1, 2016