Right Angled Triangle

Hello,

I have come across a problem that I don't have an elegant solution for...

The question is: Given a square 4 x 4 grid of dots, how many right angled triangles can you create by selecting three dots?

You could of course use a brute force method. I have considered permutations / combinations, but ran into some difficulties of eliminating solutions. I've considered approaching it through a symmetrical approach as well.

Any help on the problem will be very helpful!

Note by Jae Joon Chang
1 month, 1 week ago

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

• Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
• Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
• Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold
- bulleted- list
• bulleted
• list
1. numbered2. list
1. numbered
2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in $$ ... $$ or $ ... $ to ensure proper formatting.
2 \times 3 $2 \times 3$
2^{34} $2^{34}$
a_{i-1} $a_{i-1}$
\frac{2}{3} $\frac{2}{3}$
\sqrt{2} $\sqrt{2}$
\sum_{i=1}^3 $\sum_{i=1}^3$
\sin \theta $\sin \theta$
\boxed{123} $\boxed{123}$

Sort by:

@Jae Joon Chang - Here is the solution-

Basically what we are looking for is the number of sets of 3 points within 16 points minus the sets of 3 points that lie on the same line, or in other words are collinear.

The number of sets of 3 points within the 4x4 grid is $C^{16}_{3} = 560$

Now, on each vertical and horizontal line, there are 4 ways that you can choose 3 collinear points (Proof given at the end)

There are 4 vertical lines, and 4 horizontal lines, so the number of sets here is $4 \times 4 \times 2 = 32$

The grid has two main diagonals, and four minor diagonals (Shown in an image at the end)

Again, there are 4 ways that 3 collinear points can be chosen on the main diagonals, and 1 way on each of the minor diagonal lines.

This means, that the number of sets on the diagonals is $2 \times 4 + 4 = 12$

Thus, the answer is $560-32-12 = \boxed{516 \text{ triangles}}$

Images -

These are the 4 ways you can choose a set of 3 collinear points on a line

The green lines are the minor diagonals

Sorry for bad artistic skills :)

- 1 month, 1 week ago

@Percy Jackson - thanks for your solution. I think the 516 triangles are simply triangles, whereas the question wanted to find the number of potential right angled triangles you can get.

A friend of mine ran a C++ programme finding three points that satisfies Pythagoras' Theorem and it returned with 200 right angled triangle.

I like the idea of eliminating collinear points, but I'm not too sure on how you could look to eliminate points that create a scalene triangle.

- 1 month, 1 week ago

Oh! Right angled triangles! I missed that part. Yes, then it would be difficult to eliminate all other triangles which are not right angled...Can you share the C++ code with me if its possible?

- 1 month, 1 week ago

apologies for the formatting, but this is what my friend had put in.

IN: import itertools

IN: def is_right(a,b,c): ab2 = (a[0]-b[0])(a[0]-b[0]) + (a[1]-b[1])(a[1]-b[1]) ac2 = (a[0]-c[0])(a[0]-c[0]) + (a[1]-c[1])(a[1]-c[1]) bc2 = (b[0]-c[0])(b[0]-c[0]) + (b[1]-c[1])(b[1]-c[1]) s = sorted((ab2, ac2, bc2)) return (s[0] + s[1] == s[2] and a != b and a != c and b != c)

IN: def righttriangles (x, y): return {frozenset((a, b, c)) for (a, b, c) in itertools.product( itertools.product(range(x), range(y)), itertools.product(range(x), range(y)), itertools.product(range(x), range(y)) ) if isright(a, b, c)}

IN: len(right_triangles(4, 4))

- 1 month, 1 week ago

ok, thanks!

- 1 month, 1 week ago