brewersfan1976

reordering_of_products.py

May 29th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. def reorderingOfProducts(boundaries, y):
  2.     array_length = len(boundaries)
  3.     x = 0
  4.     new_array = []
  5.    
  6.     while (x < array_length - 1):
  7.           new_array.append((boundaries[x] + boundaries[x + 1]) / 2)
  8.           x = x + 1
  9.    
  10.     x = 0
  11.     array_length = len(new_array)
  12.    
  13.     while (x < array_length):
  14.           print new_array[x]
  15.           if new_array[x] >= y:
  16.              return x
  17.           else:
  18.              x = x + 1
  19.    
  20.     return x
Advertisement
Add Comment
Please, Sign In to add comment