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?
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.
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.
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.