I have a list of sorted values representing angles (in degrees), all in the range [0,360)
My goal is to find the best range (minimum range) that matches all corners in the list.
Some examples:
Given a list of angles = [0,1,2,10,20,35] , the answer will be (0,35) .
Given the list angles = [10,20,340,355] , due to the circular nature of the values, the answer will be (340,20) .
My current script works as follows:
MAX_ANGLE = 360 def get_best_range(angles): number_of_angles = len(angles)
Ok, this is my best approach so far, and it works in O (n), which is good, but it seems to me that in python there may be a better way to do this. Maybe some kind of tool for working with circular values? I always have a bit of trouble when working with corners or other circular values.
source share