unit4_pp/scripts/unit4_exercise_solution.py
def find_closest_node(random_pt, node_list):
  """
  Finds the closest node in the tree
  random_pt: a [x,y] point (as a list)
  node_list: list that keeps all nodes in the tree
  returns: Node instance that is the closest node in the tree
  """
  nearest_distance = float('inf')
  for n in node_list:
    current_distance = calculate_distance(random_pt, n.coordinates)
    if current_distance < nearest_distance:
      nearest_node = n
      nearest_distance = current_distance
  return nearest_node

  Finds the closest node in the tree
  random_pt: a [x,y] point (as a list)
  node_list: list that keeps all nodes in the tree
  returns: Node instance that is the closest node in the tree
  
Finds the closest node in the tree
random_pt: a [x,y] point (as a list)
node_list: list that keeps all nodes in the tree
returns: Node instance that is the closest node in the tree
Finds the closest node in the tree random_pt : a [ x y ] point ( as a list ) node_list : list that keeps all nodes in the tree returns : Node instance that is the closest node in the tree
def find_closest_node(random_pt, node_list):
  nearest_distance = float('inf')
  for n in node_list:
    current_distance = calculate_distance(random_pt, n.coordinates)
    if current_distance < nearest_distance:
      nearest_node = n
      nearest_distance = current_distance
  return nearest_node
def find_closest_node ( random_pt , node_list ) : nearest_distance = float ( 'inf' ) for n in node_list : current_distance = calculate_distance ( random_pt , n . coordinates ) if current_distance < nearest_distance : nearest_node = n nearest_distance = current_distance return nearest_node
Finds the closest node in the tree
random_pt: a [x,y] point (as a list)
node_list: list that keeps all nodes in the tree
returns: Node instance that is the closest node in the tree
Finds the closest node in the tree random_pt : a [ x y ] point ( as a list ) node_list : list that keeps all nodes in the tree returns : Node instance that is the closest node in the tree
"""
  Finds the closest node in the tree
  random_pt: a [x,y] point (as a list)
  node_list: list that keeps all nodes in the tree
  returns: Node instance that is the closest node in the tree
  """
random_pt
node_list