class Triangle(object): def __init__(self, a, b, c): self.a = a self.b = b self.c = c def check(self): for x in range(1,self.a): y = self.a - x z = self.c - y if False: print(x, y, z) print(self.a, x + y) print(self.b, x + z) print(self.c, y + z) print('-----') if self.b == x + z: self.x = x self.y = y self.z = z return True return False def print3(t): print(' ▁▁▁▁▁▁▁▁▁▁▁') print(' {0:3} ▏ {1:3} ▕ {2:3} '.format( t.a, t.x, t.b)) print(' ▏{0:3} | {1:3}▕'.format(t.y, t.z)) print(' ▔▔▔▔▔▔▔▔▔▔▔') print(' {0:3}'.format(t.b)) count_ex = 0 count_ok = 0 for a in range(1,101): for b in range(1,101): for c in range(1,101): count_ex += 1 t = Triangle(a, b, c) if t.check(): count_ok += 1 print3(t) print(count_ex) print(count_ok)