enter image description here

How many triangles are in this picture? Is there any formula or computer software to calculate this?

Also: I know programming so I can program something to solve this if someone can point out an algorithm for this.


Here's a simple but tedious algorithm for you: Label the vertices $A, B, C, \ldots, N$. Now go through all triples in alphabetical order (thus $ABC, ABD, ABE, \ldots, LMN$) and check whether they form a triangle.

To improve this somewhat, take advantage of the symmetry. There are four vertices on the central axis; call them $A,B,C,D$. The others come in pairs: $E_1, E_2, F_1, F_2, \ldots, I_1, I_2$. Count the triangles that do not have vertical symmetry, and multiply by two. Then add to this count the triangles that do have vertical symmetry.

  • $\begingroup$ Nice way to describe "brute force counting $3$-cycles" algorithm. :) (the former) $\endgroup$ – Alexey Burdin Jun 3 '15 at 1:59
  • $\begingroup$ Can this be done for rectangles as well? $\endgroup$ – user3932000 Jun 3 '15 at 2:19
  • $\begingroup$ @user3932000: Sure; in the case of rectangles, the fourth vertex is determined by the other three, so you can still go through triples. $\endgroup$ – Théophile Jun 3 '15 at 2:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.