Right Triangles

Algebra Level 3

How many right triangles can be formed using the points of the square lattice below?


The answer is 200.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Hongqi Wang
Nov 13, 2020
  • one edge is horizontal and the other is vertical. select one row, then pick up 2 dot from a row and the other dot from other row but in the same column with one of two first dots: 4 × ( 4 , 2 ) × 3 × 2 = 4 × 4 × 3 2 × 3 × 2 = 144 4 \times (4,2) \times 3 \times 2 = 4 \times \frac {4 \times 3}{2} \times 3 \times 2 = 144

  • one right edge is 2 \sqrt 2 . each of 8 outer dots (except for 4 vertexs) has 2 cases, each of 4 inner dots has 6 cases: 8 × 2 + 4 × 6 = 40 8 \times 2 + 4 \times 6 = 40

  • one right edge is 5 \sqrt 5 . each outer dot has 1 case and each inner dot has 2 cases: 8 + 4 × 2 = 16 8 + 4 \times 2 = 16

So total: 144 + 40 + 16 = 200 144 + 40 + 16 = 200

Nice enumeration. Any ideas for a formula for how many right-angled triangles can be made on an n × n n \times n grid?

Chris Lewis - 6 months, 3 weeks ago
Fletcher Mattox
Nov 13, 2020
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from itertools import combinations

class Point(object):
    def __init__(self, x, y): 
        self.x = x
        self.y = y

def dist_squared(P, Q):
    return (Q.x - P.x)**2 + (Q.y - P.y)**2

def is_right(A, B, C):
    a = dist_squared(B, C)
    b = dist_squared(A, C)
    c = dist_squared(A, B)
    a, b, c = sorted([a, b, c])
    return c == a + b

def right_triangles(N):
    count = 0
    for t in combinations(range(N*N), 3):
        triangle = []
        for i in t:
            P = Point(i%N, i//N)
            triangle.append(P)
        A, B, C = triangle
        if is_right(A, B, C): 
            count += 1 
    return count

print(right_triangles(4))

1
200

This is on OEIS , by the way. According to a comment on that site, there's no known formula for the number of right-angled triangles that can be made on an n × n n \times n grid...how enticing...

Chris Lewis - 6 months, 3 weeks ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...