Problem 46565. Find an inscribed square on a closed curve
Solution Stats
Problem Comments
-
5 Comments
Your test suite just checks whether a quadrilateral has equal sides, but that's not enough to form a square: rhombuses also have equal sides. Therefore, the test suite should also check a solution's angles.
PS: A test case filled with rhombuses and a single square on the curve would be instructional too.
Test suite has been updated to check for a solution's angles as well and a mixed test case with rhombus and square mixed has been added.
Solutions have been rescored as well.
Where is the square in the last test? The test passes with [1 3 5 7], but that's a rhombus. The angle test works because the dot products are 3, 3, -3, -3, and their sum is still zero. Perhaps checking that all dot products are zero (or less than a tolerance) would work.
Hello Chris, there is actually a typo from my side in the last test case.
Point #6 is supposed to be (1,-1) instead of (-1, 1) (which occurs twice).
I am unable to correct the test suite at this moment, I will update it inline with your feedback, as soon as I can.
Hello Chris, I have corrected the test case #7 and modified the test suite as per your suggestion.
Also, I have rescored the solutions.
It was interesting to see that quite a many solutions failed the last test case, incorrectly giving the rhombus as the solution
(i.e [1 3 5 7]).
Solution Comments
Show commentsProblem Recent Solvers5
Suggested Problems
-
72 Solvers
-
Return the 'Size' of a String of Code
126 Solvers
-
Similar Triangles - find the height of the tree
300 Solvers
-
339 Solvers
-
Sums of Multiple Pairs of Triangular Numbers
236 Solvers
More from this Author50
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!