The Ruby pythagorean triplet exercise has something wrong with it #1497

First the documentation isn’t clear: “max_factor” and “min_factor” aren’t defined.
If they are taken to be largest side and smallest side of the triangle (which would be better names frankly) then the tests are wrong.
One test has a max_factor of 10, and according to this website: A084645 - OEIS a Pythagorean triangle with a hypotenuse of 10 has only one solution. Yet the tests have two products possible: 60 and 480 (I got a result with 480 but not 60).
Another test has a max_factor of 100 and three solutions but only 2 should exist: A084646 - OEIS

The read-me has no mention of this max_factor or min_factor may mean.

Secondly, the example solution is very complicated. Hard to spot if the logic of the example is wrong.

@rebelwarrior Could you post some example code that you think is correct but that is failing, or that you think is incorrect but is passing please :slight_smile:

The exercise is not broken. With mentoring I was able to figure out what the instructions should have been. The issue is the instructions don’t match what the exercise wants you to do very well and left me confused.
The instructions only refer to the sun of a Pythagorean triplet but the exercise has Max and min factors that aren’t defined. Not to mention that the return value (an array of Triplet class objects) is not stated so my first instinct was to return an array of arrays.

Max factor in this case means the Max value possible of any of the triplet sides not the size of the largest side.
The return value of Triplet.where is an array of triplets so that’s not explicitly stated.
And there is no factoring.
I’ll see if I can write a better description and submit a pull request to the read me in the future.

Frankly min and max are better names than max and min factor.

@rebelwarrior Thanks. It seems like the Ruby version of this exercise is quite different from how it is in other tracks. I suspect it needs syncing with the main corpus. @kytrinyx Could you take a look pls?

Yepp, I’ll take a look next week.

1 Like

Next week has come, and the pull request is almost complete.

1 Like