solution to the "elevator problem"