Skip to content

pythagorean-triplet (incorrect) missing tests? #633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cdekok opened this issue Aug 21, 2018 · 5 comments
Closed

pythagorean-triplet (incorrect) missing tests? #633

cdekok opened this issue Aug 21, 2018 · 5 comments

Comments

@cdekok
Copy link

cdekok commented Aug 21, 2018

Shouldn't the test do something with the input to calculate the pythagorean-triplet? Also the test was not ignored and there was only one.

All but the first test have been ignored. After you get the first test to pass, open the tests source file > which is located in the tests directory and remove the #[ignore] flag from the next test and get the tests to pass again. Each separate test is a function with #[test] flag above it. Continue, until you pass every test.

https://github.com/exercism/rust/blob/master/exercises/pythagorean-triplet/tests/pythagorean-triplet.rs

@ZapAnton
Copy link
Contributor

A little note: The text you have pasted in your comment is a common template that looks the same across every exercise, so no need to read very hard in it.
It seems like there is no canonical data for this exercise and there is already an issue about it. So the solution could be:

  • wait until canonical data is implemented and update the test suite
  • ignore the canonical data and manually add tests to the suite

@petertseng
Copy link
Member

The README at https://github.com/exercism/rust/blob/master/exercises/pythagorean-triplet/README.md only says "There exists exactly one Pythagorean triplet for which a + b + c = 1000. / Find the product a * b * c." so whoever implemented this exercise in #333 chose to follow the README strictly and only ask for this problem. Adding tests would be a departure from the README. I think I'd recommend changing https://github.com/exercism/problem-specifications/blob/master/exercises/pythagorean-triplet/description.md first so that we are not limiting the change to this track; we wouldn't want to be selfish.

@petertseng
Copy link
Member

There was once discussion of this issue (not considering the input) in exercism/problem-specifications#1211 . There is not (yet) anyone who has chosen to do something about it. However I listed some possibilities in the issue.

@cdekok
Copy link
Author

cdekok commented Aug 22, 2018

Aside from the description to build the implementation, it will probably be a good idea to include some links to documentation to help solve the problem. For me at least it was a suprise to see the first exercise considerably more difficult then the hello world intro without any introduction, but perhaps you expect the person to already have some programming experience and figure it out themselves?

@coriolinus
Copy link
Member

There are several ways to solve the pythagorean triplet problem. The naive solution is to write a pair of loops to generate and test triplets; loops are pretty fundamental to any language. An only slightly more advanced solution is to use iterators to do the same thing.

A moderately advanced solution would be to use recursive descent to solve the problem at compile-time without loops or iterators, such that the assembly contains just a constant. Rust's nightly compiler almost supports this, but as of last week, it's not quite there yet. (It was still fun to try.)

An advanced solution would be to treat it as a math problem, solve by hand, and submit a solution with a hard-coded number and several comments about the approach taken. A cheating solution would be to take that number from the tests file, and then write a brief comment falsely claiming that you solved it as a math problem.

Given the variety of approaches possible, I'd prefer not to write a comment suggesting any one of them, to avoid priming people in a way which would make it harder for them to think up their own approach. Still, if you feel strongly about this, I am willing to review a PR adding text to .meta/hints.md helping people get started.

In the meantime, I will close this issue, as there is no direct action we can take to resolve it.

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

No branches or pull requests

4 participants