8 kyu
Sum of differences in array
13,243 of 28,617kamilalew
Description:
Your task is to sum the differences between consecutive pairs in the array in descending order.
Example
[2, 1, 10] --> 9
In descending order: [10, 2, 1]
Sum: (10 - 2) + (2 - 1) = 8 + 1 = 9
If the array is empty or the array has only one element the result should be 0
(Nothing
in Haskell, None
in Rust).
Arrays
Fundamentals
Similar Kata:
Stats:
Created | Aug 15, 2018 |
Published | Aug 15, 2018 |
Warriors Trained | 51559 |
Total Skips | 2599 |
Total Code Submissions | 130355 |
Total Times Completed | 28617 |
JavaScript Completions | 13243 |
C++ Completions | 4125 |
Haskell Completions | 276 |
Java Completions | 3410 |
C Completions | 678 |
NASM Completions | 29 |
Ruby Completions | 383 |
C# Completions | 1048 |
λ Calculus Completions | 10 |
Python Completions | 5441 |
Lua Completions | 139 |
Julia Completions | 40 |
Rust Completions | 403 |
TypeScript Completions | 460 |
Scala Completions | 28 |
Total Stars | 518 |
% of votes with a positive feedback rating | 90% of 2839 |
Total "Very Satisfied" Votes | 2350 |
Total "Somewhat Satisfied" Votes | 400 |
Total "Not Satisfied" Votes | 89 |
Total Rank Assessments | 12 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 8 kyu |