|
|
back to boardTest #8 : Run-time error; Python script: help me fellas In a different IDE with all boundary conditions checked, it's working but it shows run-time error at test #8, not sure why. import sys def compute_sum(n): return int(n[0]) + int(n[1]) + int(n[2]) - int(n[3]) - int(n[4]) - int(n[5]) n = input() s2 = 1 s3 = 1 if int(n) == 0 or int(n) == 999999: print ('Yes') sys.exit() s1 = compute_sum(n) if len(str(int(n))) < 6: d = 6 - len(str(int(n))) s2 = compute_sum('0' * d + str(int(n) - 1)) s3 = compute_sum('0' * d + str(int(n) + 1)) else: s2 = compute_sum(str(int(n) - 1)) if len(str(int(n) + 1)) <= 6: s3 = compute_sum(str(int(n) + 1)) if abs(s2) == 0 or abs(s3) == 0: print ("Yes") else: print ("No") |
|
|