input: Write a python function to normalize a list of numbers such that each element is replaced by either the minimum or maximum value depending on which is closer.
  assert normalize([5, 4, 3, 4, 8, 6, 7]) == [5, 4, 3, 5, 8, 6, 7]
  assert normalize([1, 2, 3, 4, 5]) == [1, 1, 1, 5, 5]
  assert normalize([10, 15, 20, 25, 30]) == [10, 10, 20, 30, 30]
output: def normalize(lst):
      if not lst:
          return lst
      min_val = min(lst)
      max_val = max(lst)
      return [min_val if abs(x - min_val) <= abs(x - max_val) else max_val for x in lst]