+ 1
Coding a lift
imagine there was one lift in an 10 storey building, what algorithm would u use to ensure optimum performancebof the lift
3 Answers
+ 4
I'd call the front desk and complain when it isn't working. :)
Elaborate upon question if you can, I'm not sure I understand what you're asking. If you're asking how an elevator works, then it's as simple as the end variable is whatever highest number was pushed while moving in that particular direction. So lets say someone pushes 3, 5, 7, and while that is happening, someone on floor 2 hits the call elevator button. It will ONLY go up first until it gets to 7, and then at that point it'll go back down. Of course, if someone on 6 hit the button while this is happening, it'll stop for them and anyone else in between. If that person on 6 was going to 1 and the person on 2 was trying to go to 9, then it'll go down to 1 prior to moving back in the upward direction. Get what I mean? The further number up/down becomes that end variable that triggers it to go in the other direction afterwards.
It's worth noting, I don't know shit about elevators. The most thought I've ever put into them this right here, and it's purely speculation. lol If you're wanting a code example, it's pretty simple stuff when you break it down.
+ 1
lets say its on the fifth floor, 4 people get in, they press 2,3,6 and 8, will the lift go descend or ascend first
+ 1
You call an elevator saying you wish to go up or down so when it arrives it already knows what request was made first and will go in that direction (displaying a lite arrow.)