https://github.com/arjunrn/messy-solution
https://github.com/arjunrn/messy-solution
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/arjunrn/messy-solution
- Owner: arjunrn
- Created: 2015-05-30T14:11:19.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-05-30T16:43:52.000Z (about 11 years ago)
- Last Synced: 2025-01-01T12:45:44.457Z (over 1 year ago)
- Language: Go
- Size: 113 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Solution
###Assumptions
1. The unit of time is the time for an elevator to move a single floor.
2. Moving up or down takes the same amount of time.
3. All elevators take the same amount to time for a unit.
### Instruction to Run
`go run *.go`
Enter the number of floors in the building the number of elevators
Enter Number of Elevators: 5
Enter Number of Floors: 20
Then run the simutation by stepping forward or submitting a request for the elevator
Enter Your Choice
Summon Elevator(S) ; Step Forward(F) ; Print Status (P); Exit(X)
s
Floor, Destination: 13 18
The elevator selected to service the call is: 0
It has to travel 18 floors.
Enter Your Choice
Summon Elevator(S) ; Step Forward(F) ; Print Status (P); Exit(X)
f
Moving
Enter Your Choice
Summon Elevator(S) ; Step Forward(F) ; Print Status (P); Exit(X)
f
Moving
## Lessons learnt
There should a 2 queues for the elevator. One queue is where it has to pickup passengers and the other where is has to drop them off. When the elevator picks up a passenger it should prompt for input. Unfortunately, this solution does not have this. As a result even the lift does not travel in the opposite direction. For example if the lift is on floor 10 and it has to pickup a passenger at floor 6 and deposit them at floor 8 it will only go from floor 10 to floor 6 stopping at floor 8 on the way.