Each time you take a step the timer for the password to be cycled progresses by one, and it takes the timer to hit 40 for the password to change. Try to move around so that when you view the current password the timer has just reset and then go input it. (The last gate needs more than 40 steps to get from the screen to the gate so you will have to input the answer for the next password in the cycle.)