8 kyu
Sum of differences in array
13,015 of 27,661kamilalew
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 | 50155 |
Total Skips | 2524 |
Total Code Submissions | 127134 |
Total Times Completed | 27661 |
JavaScript Completions | 13015 |
C++ Completions | 3836 |
Haskell Completions | 271 |
Java Completions | 3342 |
C Completions | 659 |
NASM Completions | 28 |
Ruby Completions | 379 |
C# Completions | 995 |
λ Calculus Completions | 9 |
Python Completions | 5177 |
Lua Completions | 135 |
Julia Completions | 39 |
Rust Completions | 376 |
TypeScript Completions | 430 |
Scala Completions | 27 |
Total Stars | 507 |
% of votes with a positive feedback rating | 90% of 2787 |
Total "Very Satisfied" Votes | 2302 |
Total "Somewhat Satisfied" Votes | 396 |
Total "Not Satisfied" Votes | 89 |
Total Rank Assessments | 12 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 8 kyu |