Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
An identical kata has been approved already, so this one should be unpublished.
Thank you! :)
Alright, obviously I did not read the test code properly. Good work!
I did it using polar coordinate system. Each vertex has increasing angle (from 0 to 2PI-0.02 at last point) and not zero distance from (0,0). So, it can't intersect itself.
Ok, but how do you ensure that your randomly created polygon meets these criteria?
"Your task is to determine the area of a polygon that does not intersect itself and has no holes. You are given the coordinates of its vertices in the double[n][2] array. Coodinates will describe a polygon in counterclockwise order. The input is always valid."
Wiki: In geometry, a simple polygon is a polygon that does not intersect itself and has no holes.
I don't see, how you can fix 2. and 3. with the description ;-)
1 So, is it not enough? If algorithm can calculate single random test what is the point for more tests?
2 & 3. It is poor task description, I think. My fault, thank you.
4 Done.
Removed the test, thank you.
[[0,0],[1,1],[1,0],[0,1]]
. The standard approach will lead to an area of0
here, but one would say that the area is0.5
.[[0,0],[0,1],[1,1],[0,1],[0,0],[0,1],[1,1],[0,1]]
. The standard approach will lead to an area of2
here, but one would have no idea what the area of this polygon is since it depends on your definition of "interior".null
test case should either be mentioned or removed. You also do not pass invalid arrays to the method, where the inner dimension is unequal to2
. So either you only give valid inputs or you demand checking on validity.Null handling is not specified anywhere and only appears in the tests, and frankly it's pointless since it doesn't add anything to the task.