Sometimes, while in competitive programming, we might be facing a problem which is of geometry domain and works with x-y coordinate system. The list of tuple can be used to store the same. And along with this, there might be a problem in which we need point with max value of x axis with similar y axis i.e farthest point on horizontal lines. Let’s discuss certain ways to discuss this problem.
Method : Using list comprehension +
This is a generic brute force method applied to get the max x axis point for common y axis, made as 1 liner using list comprehension. The
max() is used to find the max of x axis element.
The original list is : [(1, 6), (4, 6), (2, 6), (6, 8), (1, 8), (2, 9)] The list after filtering just maximum points on lines : [(4, 6), (6, 8), (2, 9)]
- Python Program for Number of jump required of given length to reach a point of form (d, 0) from origin in 2D plane
- Python Desktop News Notifier in 20 lines
- Python program to copy odd lines of one file to other
- Python Tkinter | Create different type of lines using Canvas class
- Floating point error in Python
- Python PIL | Image.point() method
- Python | Record Point with Minimum difference
- Python | Single Point Crossover in Genetic Algorithm
- Python regex | Check whether the input is Floating point number or not
- Count of lines required to write the given String
- Reading Python File-Like Objects from C | Python
- Python | Convert list to Python array
- Important differences between Python 2.x and Python 3.x with examples
- Python | Index of Non-Zero elements in Python list
- Python | Merge Python key values to list
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.