7 kyu

Near or Far

Description:

The explorer Indian A. Junes is lost... Help him find the exit of the dungeon!

In his hand is a magical map of (n x m) dimensions with coordinates (0, 0) and (n-1, m-1)as the top-left and bottom-right corners respectively. Not completely helpless while exploring, he recorded two points A and B that are equidistant to the exit. Now, you only need to find all possible exits from the map!

For example:

n = 4
m = 3
A = (1, 1)
B = (2, 2)

will be reflected into a 2D map, as:

[[*  *  *  *]
 [*  A  *  *]
 [*  *  B  *]]

It can be seen that points (2, 1), (1, 2) and (3, 0) are equidistant to points A and B. which should be returned as a list of tuples sorted in increasing order of values:

returned_value = [(1, 2), (2, 1), (3, 0)]

Constraints:

  3 <= n,m <= 100
  ans = List of tuples or empty list
  Distances between points are measured in euclidean distances.

If you don't know euclidean distance formula, check here.

Note: There are cases where there are no coordinates equidistant to both points, don't expect to always have a common point!

Arrays
Algorithms
Geometry
Mathematics

Similar Kata:

Stats:

CreatedJan 17, 2021
PublishedJan 17, 2021
Warriors Trained421
Total Skips86
Total Code Submissions457
Total Times Completed129
Python Completions129
Total Stars4
% of votes with a positive feedback rating82% of 47
Total "Very Satisfied" Votes32
Total "Somewhat Satisfied" Votes13
Total "Not Satisfied" Votes2
Total Rank Assessments36
Average Assessed Rank
7 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • SeraphWedd Avatar
  • dfhwze Avatar
Ad