8 kyu
Sum of differences in array
13,083 of 27,948kamilalew
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 | 50616 |
Total Skips | 2556 |
Total Code Submissions | 128111 |
Total Times Completed | 27948 |
JavaScript Completions | 13083 |
C++ Completions | 3920 |
Haskell Completions | 276 |
Java Completions | 3367 |
C Completions | 662 |
NASM Completions | 29 |
Ruby Completions | 381 |
C# Completions | 1008 |
λ Calculus Completions | 9 |
Python Completions | 5260 |
Lua Completions | 136 |
Julia Completions | 39 |
Rust Completions | 384 |
TypeScript Completions | 436 |
Scala Completions | 27 |
Total Stars | 510 |
% of votes with a positive feedback rating | 90% of 2800 |
Total "Very Satisfied" Votes | 2312 |
Total "Somewhat Satisfied" Votes | 399 |
Total "Not Satisfied" Votes | 89 |
Total Rank Assessments | 12 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 8 kyu |