When it comes to city planning it's important to understand the borders of various city structures. Parks, lakes or living blocks can be represented as closed polygon and can be described using cartesian coordinates on a map. We need a functionality to determine if a point (a building or a tree) lies inside the structure.
For the purpose of this mission, a city structure may be considered a polygon represented as a sequence of vertex coordinates on a plane or map. The vertices are connected sequentially with the last vertex in the list connecting to the first. We are given the coordinates of the point which we need to check. If the point of impact lies on the edge of the polygon then it should be considered inside of it. For this mission, you need to determine whether the given point lies inside the polygon.
For example, on the left image you see a polygon which is described by
[[2, 1], [1, 5],[5, 7], [7, 7], [7, 2]] and the point at [2, 7]. The result is False.
For the right image the point lies on the edge and gets counted as inside the polygon, making the result True.
Input: Two arguments. Polygon coordinates as a list of lists with two integers each. A checking point coordinates as a list of two integers.
Output: Whatever the point inside the polygon or not as a boolean.
is_inside([[1, 1], [1, 3], [3, 3], [3, 1]), [2, 2]) == True is_inside([[1,1], [1, 3], [3, 3], [3, 1]), [4, 2]) == False
How it is used: This concept is using for image recognizing. But as we said early it can be useful for topographical software and city planning.
all(x ≥ 0 and y ≥ 0 for x, y in polygon)
point ≥ 0 and point ≥ 0
CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.
In order to install CheckiO client you'll need installed Python (version at least 3.8)
Install CheckiO Client first:
pip3 install checkio_client
Configure your tool
checkio --domain=py config --key=
Sync solutions into your local folder
(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)
checkio serv -d
Alternatevly, you can install Chrome extension or FF addon
checkio install-plugin --ff
checkio install-plugin --chromium
Read more here about other functionality that the checkio client provides. Feel free to submit an issue in case of any difficulties.