# Triangle exercise, instructions improvement

Just did the Triangle exercise and noticed the instructions include the following note:

#### Note

For a shape to be a triangle at all, all sides have to be of length > 0, and the sum of the lengths of any two sides must be greater than or equal to the length of the third side.

### Correction:

The sum of the length of two sides should be greater than the length of the third side.

What is incorrect about the note?

@Octanoz Try to draw a triangle where the sum of two sides is equal to or smaller than the third side.

There is a known name for that, where you not only try but you succeed to do so. It is a degenerate triangle. This has been discussed since 2016 if you are interested in the discussion, that may be a lead to other information sources as well.

Heh, I wasn’t planning on having a philosophical debate on degenerate triangles but afaik if the sides are longer than 0 (i.e. we can physically observe them), they can’t all be the same length and still form a triangle.

if the sides are longer than 0 (i.e. we can physically observe them), they can’t all be the same length and still form a triangle.

I think the name for all the same length is Equilateral Triangle, so that is a different thing, and it is a valid triangle.

Yes, I see you did say “if” and whatever afaik means, probably an expletive to make that “if” louder more pronounced, so it did not go unnoticed.

Sorry, sorry, I left out a bit in my previous reply and confused everyone, probably.

The thing I meant to point out in the original post is that the instructions say the sum of the length of two sides is larger than or equal to the length of the third side.

My point was that the sum of the length of the other two is always larger than the length of the third in order to be a valid triangle.

Following from that logic, the mention that all sides should be longer than 0 is already covered by the previous rule because any side being 0 long would break that rule.

(afaik = As Far As I Know) ;)

The length of two sides being equal to the length of the third side is precisely what creates a degenerative triangle, and we have decided to accept degenerative triangles (which would would of course produce a line of three segments, the two segments of which would equal the length of the third) as a valid triangle.

So the key point, or the invalidating phrase, is the opposite of that statement that you show in bold would be: the sum of the length of two sides being smaller than the length of the two sides would not create a triangle of any kind.

The discussion of why we accepted this (somewhat) unpopular position is stored away and may be found with the breadcrumb I left in this message.

The statement is missing the other part of the, which is that the sum of the two sides may also be equal to the length of the third side.

I believe this is why @IsaacG asked which part was wrong. This correction would invalidate most if not all the tracks that use the canonical data, as it concerns this exercise.

The exact quote from the description says this:

``````For a shape to be a triangle at all, all sides have to be of length > 0, and the sum of the lengths of any two sides must be greater than or equal to the length of the third side.
``````

And it is correct:

1. all sides must be of a length greater than 0
2. the sum of the length of two sides must be greater than or equal to the length of the third side.

There is no incorrect statement there, and covers isosceles, scalene, equilateral, and degenerate triangles.

Further information: ref 1

• A degenerate triangle is a “flat” triangle in the sense that it is contained in a line segment. It has thus collinear vertices[3] and zero area. If the three vertices are pairwise distinct, it has two 0° angles and one 180° angle. If two vertices are equal, it has one 0° angle and two undefined angles. If all three vertices are equal, all three angles are undefined.

Ok, I can’t say that I have checked the tests for different languages. I’m also not a mathematician (shocker).

If it’s important that a degenerate triangle is considered and it is something being checked for in some languages then I am indeed incorrect with my point.

I was able to pass all tests without ever having to check if all sides are >0 because I already checked that side 1 + side 2 > side 3, etc., etc.

It may be in that track the degenerative triangle was not tested for. There are variances in the tracks for some exercises, and some maintainers will accept or deny some tests. This makes sense as well, since languages are sometimes different enough that certain problems are interesting to solve and know about while others are boring and mundane.

Since you have not mentioned a language track specifically, I presume that you mean the canonical information as presented in problem-specifications, while specific tracks “description” or “readme” or “instruction” files may stray from that to some extent.

To expand on that, I am almost positive that the tests for greater than zero are there, at least tangentially. Even a degenerative triangle would have all sides greater than 0 to be valid, as stated in the description. So if there is a test that violates this statement, this is important to know and to correct. (The description should not contradict the tests in any way, while also not necessarily being fully and exhaustively descriptive.)