Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rightTriangles = []
- def angleCheck(x1, x2, y1, y2):
- zeroCount, undefCount = 0, 0
- try:
- slope1 = y1/x1
- if slope1 == 0:
- zeroCount += 1
- except ZeroDivisionError:
- undefCount += 1
- try:
- slope2 = y2/x2
- if slope2 == 0:
- zeroCount += 1
- except ZeroDivisionError:
- undefCount += 1
- try:
- slope3 = (y2-y1)/(x2-x1)
- if slope3 == 0:
- zeroCount += 1
- except ZeroDivisionError:
- undefCount += 1
- if zeroCount == 1 and undefCount == 1:
- return True
- if zeroCount > 1 or undefCount > 1:
- return False
- if -y1*y2 == x1*x2:
- return True
- if -(y2-y1)*y1 == (x2-x1)*x1:
- return True
- if -(y2-y1)*y2 == (x2-x1)*x2:
- return True
- return False
- for a in range(51):
- for b in range(51):
- for c in range(51):
- for d in range(51):
- if a == c == 0:
- continue
- if b == d == 0:
- continue
- if a == b and c == d:
- continue
- if angleCheck(a, b, c, d):
- if sorted([(a, c), (b, d)]) in rightTriangles:
- continue
- rightTriangles.append(sorted([(a, c), (b, d)]))
- print(len(rightTriangles))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement