I believe my solution is correct, but it is failing the test.
I believe the test already reflects the problem statement. Please keep in mind that one of the requirement is for the six numbers to be unique.
Yes, my six numbers are unique. However, because this puzzle involves floating point ratios, there is an issue with rounding. The test for equality needs to include a tolerance.
The answers are integers. So, proper fractions are involved and they should be able to be simplified to satisfy the equality. I hope this helps.
I know that, but your second test is a test on the ratios of integers, and these are floating point numbers that may not be exactly equal. So you need to include a tolerance, or else express the condition in terms of integer quantities. Example: test for a*d*f = c*b*f - e*b*d.
A word to the wise: So far I have found 5 correct solutions to this problem, but they all fail the second assertion because of the way it is written. If the assertion were written as assert(y(1)*y(4)*y(6) == y(3)*y(2)*y*6) -y(5)*y(2)*y(4)), then they would all pass, but until that change is made, most correct solutions will fail. An alternative is to put a tolerance in the second assertion as it is now written.
A tolerance has been added to the test suite.
Is the Point in a Triangle?
Flip the vector from right to left
Number Puzzle - 062
Number Puzzle - 075
Temperature Conversion 3
Matrix Pattern 10
Number Puzzle - 111
Number Puzzle - 052
Matrix Pattern 2
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office