author | Madhusudan.C.S <madhusudancs@gmail.com> |
Tue, 31 Aug 2010 20:14:18 +0530 | |
changeset 114 | 83b3e357ed08 |
parent 111 | a6a442d1bbd9 |
permissions | -rw-r--r-- |
def gcd(a, b): while b != 0: a, b = b, a % b return a if __name__ == '__main__': for line in open('gcd_testcases.dat'): values = line.split(', ') a = int(values[0]) b = int(values[1]) g = int(values[2]) tc = gcd(a, b) if tc != g: print "Test failed for the case a=%d and b=%d. Expected %d. Obtained %d instead." % (a, b, g, tc) exit(1) print "All tests passed!"