Skip to content

Instantly share code, notes, and snippets.

@lettergram
Created March 18, 2015 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lettergram/961c558f172c25ff3f00 to your computer and use it in GitHub Desktop.
Save lettergram/961c558f172c25ff3f00 to your computer and use it in GitHub Desktop.
# (Index * 5 seconds) + (20 seconds * (Index - PrevIndex))
# If previous elevators loops/stops add up to be greater than,
# (timePerFloor * 2) + timePerWait, then increase floor of previous
# elevators loop. i.e. elevator[2]+=1
# e represents elevatorArray
def addFloor(e):
best = 99999
for i in range(1, len(e)):
cirTime, avgCarry = eleLoop(e, i)
if cirTime + ((cirTime / 100) * avgCarry) < best:
elevatorNumber = i
best = cirTime + ((cirTime / 100) * avgCarry)
for i in range(elevatorNumber, len(e)):
e[i] += 1
return e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment