How many triangles are there?

@Sp3000 is right, this is actually $PE-163$, and your particular case is given in the problem statement $ T(2) = 104.$

But if you are looking for a general formula to count the number of triangles in higher order then check here, (spoiler for the original PE problem).


You can model this using the graph theory. Then make an algorithm that will solve the problem.

Every line that ends connecting more than one line is a node. Find all nodes. Then start from one and look for graphs that contain 3 elements.


I think I found an easier solution for this specific problem without complicating it too much.

We have one basic kind of triangle, and that is the one that our big triangle contains 4 of. Let's call that order 1.

If we count the triangles inside order 1, we find out that they are 16. They are not so many so we can actually count them manually.

So long we have 16 triangles times 4, 64 triangles.

Now by combining 4 order-1 triangles we get new triangles that originate from the combination.

Lets count the new triangles for ONE side only. Be careful because some of them can be mirrored and some cannot. Actually there is only one that cannot be mirrored.

That gives us 13 new triangles for ONE side only from the combination of order 1 into order 2.

Now we have 13 more for every time we turn the big triangle around. So now we have:

16*4 + 13*3 = 103

Don't forget the big triangle!

16*4 + 13*3 + 1 = 104

Woho, solved! =)


Another longish way would be to label all vertices and check if all triples give you triangles.


This forms part of a problem on the Project Euler website and as you can see your particular example is $T(2) = 104.$