7 kyu
Elevator Distance
3,421 of 9,296marbiru
Description:
Imagine you start on the 5th floor of a building, then travel down to the 2nd floor, then back up to the 8th floor. You have travelled a total of 3 + 6 = 9 floors of distance.
Given an array representing a series of floors you must reach by elevator, return an integer representing the total distance travelled for visiting each floor in the array in order.
// simple examples
[5,2,8] => 9
[1,2,3] => 2
[7,1,7,1] => 18
// if two consecutive floors are the same,
//distance travelled between them is 0
[3,3] => 0
Array will always contain at least 2 floors. Random tests will contain 2-20 elements in array, and floor values between 0 and 30.
Fundamentals
Similar Kata:
Stats:
Created | Oct 25, 2017 |
Published | Oct 25, 2017 |
Warriors Trained | 12070 |
Total Skips | 165 |
Total Code Submissions | 19505 |
Total Times Completed | 9296 |
JavaScript Completions | 3421 |
Python Completions | 3082 |
Groovy Completions | 107 |
Ruby Completions | 207 |
Julia Completions | 20 |
Rust Completions | 221 |
C Completions | 288 |
C# Completions | 374 |
C++ Completions | 1751 |
COBOL Completions | 9 |
Haskell Completions | 54 |
Scala Completions | 14 |
Java Completions | 64 |
Total Stars | 91 |
% of votes with a positive feedback rating | 94% of 1054 |
Total "Very Satisfied" Votes | 936 |
Total "Somewhat Satisfied" Votes | 107 |
Total "Not Satisfied" Votes | 11 |
Total Rank Assessments | 4 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 7 kyu |