Daily Coding Challenge - Elevator Stops

Tell us what’s happening:

Test case 5’s solution appears to be wrong. The rules said to go UP first if tied. For current floor 11, both 10 and 12 and closest to it, but the rule said to go UP first, hence the solution is wrong.

Your code so far

def elevator_stops(current_floor, stops):

    return current_floor

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:152.0) Gecko/20100101 Firefox/152.0

Challenge Information:

Daily Coding Challenge - Elevator Stops

https://www.freecodecamp.org/learn/daily-coding-challenge/2026-07-19

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/daily-coding-challenges-python/6a2037a68a0bc2aef0006005.md at main · freeCodeCamp/freeCodeCamp · GitHub

Welcome to the forum @ingvows,

I get what you’re thinking, but the tests are looking at the difference between the highest floor and the current floor (23 - 11 = 12) compared to the difference between the lowest floor and the current floor (11 - 2 = 9). Since 9 is lower than 12, you would visit the lower floors first then go up.

Happy coding

I do not understand this. Why would we need to consider the entire height of the building when cycling through a list of stops? The elevator doesn’t have to travel all the way to the top each time, it just moves between floors.

Welcome to the forum @Crag,

We’re not considering the height of the building; we’re looking at the highest floor in the requested elevator stops.

And, in Test #5 of this challenge, the highest elevator stop is on Floor 23. The building could have more floors.

Happy coding

Regardless, it seems completely unnecessary to what we are being asked to calculate. If i’m at floor 11 and my options are to go to down to floor 10 or up to floor 12. Nothing in the problem as written indicates I have to care that the floors go up to 23 in making that decision.

ah wait, I think i see what you are saying now. Appreciate the help

It’s not a “10 or 12” thing. The elevator has to stop at all of the requested floors. The decision is about whether the elevator goes up or down first.