8 kyu
Closest elevator
7,774 of 16,648wildhamster26
Description:
Given 2 elevators (named "left" and "right") in a building with 3 floors (numbered 0
to 2
), write a function accepting 3 arguments (in order):
left
- The current floor of the left elevatorright
- The current floor of the right elevatorcall
- The floor that called an elevator
It should return the name of the elevator closest to the called floor ("left"
/"right"
).
In the case where both elevators are equally distant from the called floor, choose the elevator to the right.
You can assume that the inputs will always be valid integers between 0-2.
Examples:
left right call result
0 1 0 "left"
0 1 1 "right"
0 1 2 "right"
0 0 0 "right"
0 2 1 "right"
Algorithms
Similar Kata:
Stats:
Created | Jan 10, 2019 |
Published | Jan 16, 2019 |
Warriors Trained | 24872 |
Total Skips | 389 |
Total Code Submissions | 64620 |
Total Times Completed | 16648 |
JavaScript Completions | 7774 |
Python Completions | 6250 |
C Completions | 839 |
Kotlin Completions | 938 |
PureScript Completions | 32 |
Ruby Completions | 466 |
PHP Completions | 605 |
Racket Completions | 40 |
Java Completions | 243 |
NASM Completions | 7 |
Total Stars | 235 |
% of votes with a positive feedback rating | 93% of 2401 |
Total "Very Satisfied" Votes | 2084 |
Total "Somewhat Satisfied" Votes | 280 |
Total "Not Satisfied" Votes | 36 |
Total Rank Assessments | 8 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |