Elevators Easy

+50 PTS

Before you start the test, check out our tutorial challenge

  • TYPE CODE PRACTICE CHALLENGE
  • LANGUAGES C++, C#, JAVA, JAVASCRIPT AND 6 MORE
    LANGUAGES C++, C#, JAVA, JAVASCRIPT, PHP, PYTHON2, PYTHON, RUBY, SWIFT, TYPESCRIPT
  • TIME ~10MIN

Elevators

Challenge outline

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 August 2019 competitions. Below you can find some of them:



Have fun and good luck! :)