Check if given point lies in range of any of the given towers | Python3 program to implement the above approach ; Function to check if the point ( X , Y ) exists in the towers network - range or not ; Traverse the array arr [ ] ; Stores distance of the point ( X , Y ) from i - th tower ; If dist lies within the range of the i - th tower ; If the point ( X , Y ) does not lie in the range of any of the towers ; Driver Code ; If point ( X , Y ) lies in the range of any of the towers ; Otherwise
from math import sqrt NEW_LINE def checkPointRange ( arr , X , Y , N ) : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT dist = sqrt ( ( arr [ i ] [ 0 ] - X ) * ( arr [ i ] [ 0 ] - X ) + ( arr [ i ] [ 1 ] - Y ) * ( arr [ i ] [ 1 ] - Y ) ) NEW_LINE if ( dist <= arr [ i ] [ 2 ] ) : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ [ 1 , 1 , 3 ] , [ 10 , 10 , 3 ] , [ 15 , 15 , 15 ] ] NEW_LINE X = 5 NEW_LINE Y = 5 NEW_LINE N = len ( arr ) NEW_LINE if ( checkPointRange ( arr , X , Y , N ) ) : NEW_LINE INDENT print ( " True " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " False " ) NEW_LINE DEDENT DEDENT