code: def _compute_gas_price(probabilities, desired_probability):
      first = probabilities[0]
      last = probabilities[-1]
      if desired_probability >= first.prob:
          return int(first.gas_price)
      elif desired_probability <= last.prob:
          return int(last.gas_price)
      for left, right in sliding_window(2, probabilities):
          if desired_probability < right.prob:
              continue
          elif desired_probability > left.prob:
              raise Exception('Invariant')
          adj_prob = desired_probability - right.prob
          window_size = left.prob - right.prob
          position = adj_prob / window_size
          gas_window_size = left.gas_price - right.gas_price
          gas_price = int(math.ceil(right.gas_price + gas_window_size * position))
          return gas_price
      else:
          raise Exception('Invariant')