Given a maximum limit of x – coordinate and y – coordinate, we want to calculate a set of coordinates such that the distance between any two points is a non-integer number. The coordinates (i, j) chosen should be of range 0<=i<=x and 0<=j<=y. Also, we have to maximize the set. Examples:
Input : 4 4 Output : 0 4 1 3 2 2 3 1 4 0 Explanation : Distance between any two points mentioned in output is not integer.
Firstly, we want to create a set, that means our set cannot contain any other point with same x’s or y’s which are used before. Well, the reason behind it is that such points which either have same x-coordinate or y-coordinate would cancel that coordinate, resulting an integral distance between them.
Example, consider points (1, 4) and (1, 5), the x-coordinate would cancel and thus, we will get and integral distance.
Secondly, we can observe that, we have only x+1 distinct i-coordinates and y+1 distinct j-coordinates. Thus, the size of the set cannot exceed min(x, y)+1.
Third observation is that we know that the diagonal elements are |i-j|* distance apart, thus, we take evaluate along the diagonal element of i-coordinate and calculate the j-coordinate by formula min(i, j)-i.
0 4 1 3 2 2 3 1 4 0
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Find the original coordinates whose Manhattan distances are given
- Count of integral coordinates that lies inside a Square
- Maximum Manhattan distance between a distinct pair from N coordinates
- Sum of Manhattan distances between all pairs of points
- Find a point such that sum of the Manhattan distances is minimized
- Find the point on X-axis from given N points having least Sum of Distances from all other points
- Minimum Sum of Euclidean Distances to all given Points
- Count Integral points inside a Triangle
- Number of Integral Points between Two Points
- Generate all integral points lying inside a rectangle
- Program to find the Type of Triangle from the given Coordinates
- Find all possible coordinates of parallelogram
- Coordinates of rectangle with given points lie inside
- Check if a right-angled triangle can be formed by the given coordinates
- Find whether only two parallel lines contain all coordinates points or not
- Minimum length of square to contain at least half of the given Coordinates
- Check if a right-angled triangle can be formed by moving any one of the coordinates
- Find the coordinates of a triangle whose Area = (S / 2)
- Maximum number of 2x2 squares that can be fit inside a right isosceles triangle
- Count maximum points on same line
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.