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.
The test for unique integers has been improved to accept both row and column vectors for y. Also, the description now specifies that the integers must all be different (as that was being tested anyway).
Rounding off numbers to n decimals
Check that number is whole number
Test Problem; Create a 5x5 array containing all ones
Number Puzzle - 022
Number Puzzle - 104
Number Puzzle - 030
Number Puzzle - 078
Temperature Conversion 1
Matrix Pattern 6
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