Triangles, intersecting lines, how to solve it

Sometimes, I hate how my brain works.  Last night around midnight, I saw this image on a friend’s Facebook wall; and then promptly went to sleep.  This morning, I woke up, and my brain was thinking of those triangles, and wouldn’t let me do much until I set to the task of figuring it out.  Why did this happen?  Well, I counted out the triangles, writing it out in ABC format connecting the points after labeling them in a small photo shop I did (which is bellow).  I ended up with the **SPOILER ALERT answer of 64 **.  And then, I clicked around and saw people coming up with all sorts of numbers (note, this was shared from facebook, none of my friend’s friends got it correct; when I clicked to the ‘Shared from’ thingy, I saw there were over 1000 comments, and none of the last 50 were correct.  So I put down my answer, and then saw so many people after posting saying there are so many more/so many less than that.

The one person that absolutely irked me was the idiot who said there were 7, and everything else had 4 sides.  This person had screwed up in a post I saw earlier that involved the simple order of operations 7 – 10 + 3 * 4….and she said the answer was definitely 3, even after I broke it down and showed why it was 9.  So, she already got on my nerves for being ignorant and arrogant. (When combined, that is my biggest pet peeve.) So, since she claimed that she was right in the instance of this triangle question, I set out to prove it – because that would be the simplest way to show “Hey, here’s how to do it, I hope it helps.” and hopefully edify some people.

So, I typed the triangles in ABC format, and then, since I didn’t want to paste them all in to a comment, especially when my reference image wouldn’t have been available, I put it together with my reference image. Click the left-side image for a full view.  Now, since that was done, I google’d for solving triangles, etc.  I came across something (I can’t remember where it is now, I apologize; I wish I could post the equation there as well)  Anyways, someone saying that no mathematical function exists for a geometric figure that has so many known points of reference?  Really?  Ok, so, now I can’t do anything until I find the mathematical formula to solve this type of problem.

Once you know that the answer is 64, you see that there are 4 lines coming from both A and B that is not connecting the two points, and 43=64. If you remove one line from both A and B, and then count those, you find that there are 27 triangles.  See where this is going? (# of lines)3= # of triangles.  But, that isn’t good enough for me.  What happens if they don’t have the same number of lines?  For example, if you took the outer triangle to be ANB from the test image?  What happens then? Well, you get 15 triangles.  What to the power of 3 is equal to 15?  Well, not an integer – so that general formula doesn’t work for all cases where two points have lines extending from them reaching each others most obtuse angle.  So, I worked out the pattern, and got:

Now, for those that don’t know how summations work, you take f(x) and run it through for different values of x.  For these summations, you would get (1 + 2 + 3 + .. + A)  Remember, that in this formula, the A and B are the number of lines each has that aren’t connected to each other.  So if we go back to the original problem with both having 4 lines each, we get: (1 + 2 + 3 + 4)4 + (1 + 2 + 3 + 4)4 – (4 *4) which is 40 + 40 – 16 = 64.  Sweet!  It works for the main triangle problem.  Now, if we go back to ANB where A is 2 and B is 3, we get (1 + 2)3 + (1 + 2 + 3)2 – (2*3) which is (3)3 + 6(2) – 6 breaking down to 9 + 12 -6 = 15.  Wow… so… it fits all the situations arising from two points throwing lines through space and connecting in triangular fashion!

So, since I couldn’t find a definitive source for this information via my not-so-intensive google search, I present it here!  For those that aren’t good at math, or were just looking for the answer, there you have it.  For those that ask How? to every logical/mathematical problem they are presented with – I hope this helps you understand it, and why it works.  Now, since you have the formula to solve these…

Throw that one around and see how many people say something like 10. 😉

I almost forgot!  Since this is a programming blog, I want to include code, if possible.  So, here is the code to solve this type of problem in PHP.  It can easily be ported to any other language.


No Comments Yet

There are no comments yet. You could be the first!

Leave a Comment

    Search the Blog