Triangle exercise: note is incorrect

A note was recently added to the triangle description in Triangle: explicitly exclude degenerate triangles by IsaacG · Pull Request #2579 · exercism/problem-specifications · GitHub :

We opted to not include tests for degenerate triangles (triangles that violate these rules) to keep things simpler.
You may handle those situations if you wish to do so, or safely ignore them.

But there are still test cases that violate these rules:

(0, 0, 0)
(1, 1, 3)
(1, 3, 1)
(3, 1, 1)
(7, 3, 2)

Isaac said that only (0, 0, 0) is degenerate. However, (1, 1, 3) does not follow “the sum of the lengths of any two sides must be greater than or equal to the length of the third side.”, did I overlook something?

Whether such tests are present seems to vary by language.

I think you’re right, the note shouldn’t be there in general.

1 Like

There are tests numbers that do not form a triangle. There are no tests for degenerate triangles. 1,1,3 is not a degenerate triangle.

1 Like

I apologize for the confusion.

The note defines degenerate triangles as “triangles that violate these rules” referring to “sum of the lengths of any two sides must be greater than or equal to the length of the third side.”. 1+1 is smaller than 3, so the rules are violated.

Can you please explain why exactly (1, 1, 3) is not a degenerate triangle using the definition stated in the description of the exercise?

A degenerate triangle is a triangle where the sum of two sides is exactly equal to the third side (and nonzero?). Not all numbers which violate those rules are degenerate triangle.

Degenerate triangles are a specific case that violates those rules.

Thanks for clarifying!
I think we can conclude that the description of the exercise can be improved to clear this up?

Personally, I’d rather not unless there’s a very compelling reason. The triangle instructions has been a recurring discussion without a lot of movement one way or the other.

1 Like

The choice is yours of course, but the current description is a source of confusion: see /exercism/roc/issues/182 on github (I’m not allowed to post another link)

Zig track currently have 5 tests for invalid triangles like this:

test "isosceles first triangle inequality violation" {
    const actual = triangle.Triangle.init(1, 1, 3);
    try testing.expectError(triangle.TriangleError.Invalid, actual);
}

At the same time there is a note in Instructions that says

We opted to not include tests for degenerate triangles (triangles that violate these rules) to keep things simpler. You may handle those situations if you wish to do so, or safely ignore them.

Contradiction between instructions and the tests confused me a little bit.

I like the note. I like to have both options. Please do not delete the ability to return an error if you ever care to delete the tests.

Not all invalid triangles are degenerate triangles.

1 Like

Triangles: clarify degenerate triangles by IsaacG · Pull Request #2594 · exercism/problem-specifications · GitHub was merged to clarify the note.

2 Likes