Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Clearer solution in Clear category for CheckSum by claudio.david
def checkio(data):
toDigit = lambda x: int(x) if x.isdigit() else ord(x) - 48
doubleVal = lambda x : sum(divmod(2*x,10))
reversedLst = list(filter(lambda x: x.isalnum(),data[::-1]))
doubledLst = [doubleVal(toDigit(elem)) if idx%2 == 0 else toDigit(elem) for idx,elem in enumerate(reversedLst)]
number = sum(doubledLst)
controlDigit = 0 if number%10 == 0 else 10-(number%10)
return [str(controlDigit),number]
April 29, 2015