added more samples to the test
Hello, Alfonso Nieto-Castanon. This is a very nice problem. It was interesting to see the variety of approaches used to solve it. It was also interesting to notice a few submissions failed your added test cases from circa Dec 2017. Do you allow for self-intersecting polygons, as per https://en.wikipedia.org/wiki/Polygon ?
I suspect a common solution tactic will fail badly when faced with self-intersecting polygons. —DIV
...On second thought, maybe there's no consistent definition of CW/CCW for self-intersecting polygons, such as figure-eight or bow-tie ("cross-quadrilateral") shapes.
the last test
I don't understand why the vector sizes of x and y for the last test case are both 100x15. The problem strictly says that the points are 2-dimensional. Can someone explain this?
I like the readability of this submission. However the logic of the if statement is curious to me: it seems that after setting tf to false, tf can be reset back to true. Would it be more robust to either (i) initialise tf before your loop, or (ii) include a "break" command?
Didn't realize ispolycw was in the Mapping Toolbox, and not Cody friendly.
This method (as well as several others) would fail in a more extensive test suite; for example, when x = [1,1,2] and y = [2,1,1]; or when x = [-2,-2,-4,-4] and y = [1,3,1,-1]; or when x = [-1,-1,3] and y = [-3,1,1].
@yurenchu, Thanks for pointing this out, I have added a few more test cases now
Sums with Excluded Digits
Find the two-word state names
Connect Four Win Checker
Say something funny
yet another flying fly (YAFF)
Knights and Knaves (part 1)
Fastest shortest-path-finder in the west
singularity 2.0 (really hard)
Free passes for everyone!
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