#format python import unittest f = lambda n: n%10==0 and 10 or n%10 def compute_check_mod1110(str): t = 10 for c in str: t = (2 * f(t + ord(c) - 48)) % 11 return (11 - t) % 10 class CheckTest(unittest.TestCase): def testMod112(self): self.assertEquals(5, compute_check_mod1110('0794')) self.assertEquals(5, compute_check_mod1110('00200667308')) self.assertEquals(3, compute_check_mod1110('00200667309')) self.assertEquals(8, compute_check_mod1110('00200667310')) self.assertEquals(6, compute_check_mod1110('00200667311')) self.assertEquals(4, compute_check_mod1110('00200667312')) if __name__=='__main__': unittest.main()