Inside Block
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 tuple with two integers (int) each. A checking point coordinates as tuple of two integers.
Output: Whatever the point inside the polygon or not as logic value (bool).
assert is_inside([(1, 1), (1, 3), (3, 3), (3, 1)], (2, 2)) == True assert is_inside([(1, 1), (1, 3), (3, 3), (3, 1)], (4, 2)) == False assert is_inside([(1, 1), (4, 1), (2, 3)], (3, 2)) == True assert is_inside([(1, 1), (4, 1), (1, 3)], (3, 3)) == 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.
Preconditions:
- all(x ≥ 0 and y ≥ 0 for x, y in polygon);
- point[0] ≥ 0 and point[1] ≥ 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
checkio sync
(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
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.
Welcome to Pair Programming! Engage in real-time collaboration on coding projects by starting a session and sharing the provided unique URL with friends or colleagues. This feature is perfect for joint project development, debugging, or learning new skills together. Simply click 'Start Session' to begin your collaborative coding journey!
You are trying to join a pair programming session that has not started yet.
Please wait for the session creator to join.
It looks like the creator of the pair programming session closed the editor window.
It might happen accidentally, so that you can wait for reconnection.