Problem 49983. Number Puzzles - 003
Solution Stats
Problem Comments
-
8 Comments
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).
Solution Comments
Show commentsProblem Recent Solvers27
Suggested Problems
-
Project Euler: Problem 7, Nth prime
1411 Solvers
-
Replace Nonzero Numbers with 1
386 Solvers
-
1223 Solvers
-
1187 Solvers
-
28 Solvers
More from this Author180
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!