Advertisement
Guest User

sadas

a guest
Mar 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. def checkIfSorted(homes):
  2.     l=len(homes)
  3.     i=0
  4.     while(i<l-1):
  5.         if homes[i]>homes[i+1]:
  6.             return False
  7.     return True
  8.  
  9. def positions(homes,d):
  10.     a=[]
  11.     if not (checkIfSorted(homes)):
  12.         homes.sort()
  13.     locations=[]
  14.     i=0
  15.     l=len(homes)
  16.     while(i<l):
  17.         location=homes[i]+d
  18.         locations.append(location)
  19.         i=i+1
  20.         while(i<l and homes[i]<=(location+d)):
  21.             i=i+1
  22.  
  23.     return locations
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement