Challenge overview
Hello and welcome to the challenge!
You have two elevators, A and B. Write a function which determines which of them is closest to the called floor. The function should receive three arguments: a_position
, b_position
and called_floor
- they are all integer numbers of floors, which are numbered form 0
to 2
. The function should return the name of the closest elevator - "A"
or "B"
. In the case when both distances are equal, return the name of the elevator A.
You can solve this programming contest in C#, C++, Java, Ruby, JavaScript, Python, PHP and many more languages. If you want, you can also take part in other Challenges. Below you can find some of them:
Have fun and good luck! :)