Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def checkIfSorted(homes):
- l=len(homes)
- i=0
- while(i<l-1):
- if homes[i]>homes[i+1]:
- return False
- return True
- def positions(homes,d):
- a=[]
- if not (checkIfSorted(homes)):
- homes.sort()
- locations=[]
- i=0
- l=len(homes)
- while(i<l):
- location=homes[i]+d
- locations.append(location)
- i=i+1
- while(i<l and homes[i]<=(location+d)):
- i=i+1
- return locations
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement