Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
CheckSum solution in Uncategorized category for CheckSum by capback250
# migrated from python 2.7
def checkio(chsum):
map_digits = {0:0, 1:2, 2:4, 3:6, 4:8, 5:1, 6:3, 7:5, 8:7, 9:9}
clear = [x for x in chsum if x.isalpha() or x.isdigit()][::-1]
_sum = []
for index, letter in enumerate(clear):
if letter.isdigit():
_sum.append(int(letter) if index % 2 else map_digits[int(letter)])
if letter.isalpha():
_sum.append(ord(letter) - 48 if index % 2 else sum([int(x) for x in list(str((ord(letter) - 48) * 2))]))
return [str(10 - sum(_sum) % 10 if sum(_sum) % 10 else 0), sum(_sum)]
Dec. 30, 2015