#!/usr/bin/python3
import os

#charmap =  {'A': 0, 'B': 1, 'C': 2, 'D': 3, 'E': 4,
#                       'F': 5, 'G': 6, 'H': 7, 'I': 8, 'J': 9}
#multiplier = [9, 8, 7, 6, 5, 4, 3, 2, 1]

charmap =  {'A': 0, 'D': 1, 'G': 2, 'J': 3, 'C': 4,
                        'F': 5, 'I': 6, 'B': 7, 'E': 8, 'H': 9}
multiplier = [3, 6, 9, 2, 5, 8, 1, 4, 7]

passed = 0
failed = 0

def verify(i):
        global passed, failed

        n = i[0:9]
        s = i[9]

        sum = 0
        for c in range(0, 9):
                sum += int(n[c])*multiplier[c]

        if sum%10 == charmap[s]:
                result = '\x1B[1;32mPASSED\x1B[m'
                passed+=1
        else:
                result = '\x1B[1;31mFAILED\x1B[m'
                failed+=1

        print("{}{} : {} => {} ... {}".format(n, s, sum, charmap[s], result))

if __name__ == '__main__':
        with open("charno.txt", "r") as fin:
                text = fin.read()

        x = text.split()

        for i in x:
                verify(i)

        print("{} passed.\n{} failed.".format(passed, failed))

# End of verify.py