Skip to content

triangle: Allow triangles where a+b == c#232

Merged
kytrinyx merged 2 commits intoexercism:masterfrom
petertseng:triangle-equal
Jan 30, 2016
Merged

triangle: Allow triangles where a+b == c#232
kytrinyx merged 2 commits intoexercism:masterfrom
petertseng:triangle-equal

Conversation

@petertseng
Copy link
Copy Markdown
Member

These are degenerate triangles since they're really just lines, but
they're still good enough under the triangle inequality (which
explicitly allows a+b == c) so let's go ahead and test for them.

Test for isosceles and scalene added. Equilateral is impossible.

Closes #231

@petertseng
Copy link
Copy Markdown
Member Author

Ah hold on. Should probably bump test version. There is none for this currently, so that means just make it 1.

Comment thread exercises/triangle/example.go Outdated
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

someone might be confused about why you only need to check c and not a, b. comment?

These are degenerate triangles since they're really just lines, but
they're still good enough under the triangle inequality (which
explicitly allows a+b == c) so let's go ahead and test for them.

Test for isosceles and scalene added. Equilateral is impossible.

Unfortunately, now we are at risk for failing a test case of (3, Inf,
Inf), since 3 + Inf == Inf, and Inf < Inf is false whereas previously
the test was Inf <= Inf which is true. So we might falsely declare this
triangle as isosceles when it should be NaT. So we need to add another
test to make sure that our largest side isn't +Inf.

Closes #231
@petertseng
Copy link
Copy Markdown
Member Author

Test version is added so this is ready for review.

@petertseng petertseng mentioned this pull request Jan 30, 2016
The previous change (allow a+b == c) changes test behavior, so now's as
good a time as any to add a test version. The previous version can be
considered to be 0 since it isn't present, so 1 is OK to use here.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice that most other elements of this file (KindFromSides, Kind, Equ, etc...) have some sort of explanatory comment. I chose not to include one for TestVersion since students should have gotten the drill already from previous exercises. Let me know if you disagree.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this.

@kytrinyx
Copy link
Copy Markdown
Member

Thank you!

kytrinyx added a commit that referenced this pull request Jan 30, 2016
triangle: Allow triangles where a+b == c
@kytrinyx kytrinyx merged commit 23537ea into exercism:master Jan 30, 2016
@petertseng petertseng deleted the triangle-equal branch January 30, 2016 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants