7 kyu
Nice Array
2,960 of 6,948aweleshetu
Description:
A Nice array
is defined to be an array where for every value n
in the array, there is also an element n - 1
or n + 1
in the array.
examples:
[2, 10, 9, 3] is a nice array because
2 = 3 - 1
10 = 9 + 1
3 = 2 + 1
9 = 10 - 1
[4, 2, 3] is a nice array because
4 = 3 + 1
2 = 3 - 1
3 = 2 + 1 (or 3 = 4 - 1)
[4, 2, 1] is a not a nice array because
for n = 4, there is neither n - 1 = 3 nor n + 1 = 5
Write a function named isNice
/IsNice
that returns true
if its array argument is a Nice array, else false
. An empty array is not considered nice.
Arrays
Mathematics
Fundamentals
Similar Kata:
Stats:
Created | Sep 12, 2017 |
Published | Sep 12, 2017 |
Warriors Trained | 11785 |
Total Skips | 381 |
Total Code Submissions | 44315 |
Total Times Completed | 6948 |
JavaScript Completions | 2960 |
C# Completions | 472 |
TypeScript Completions | 189 |
Python Completions | 2119 |
CoffeeScript Completions | 13 |
Crystal Completions | 11 |
Ruby Completions | 186 |
Julia Completions | 31 |
Dart Completions | 268 |
PHP Completions | 223 |
Java Completions | 729 |
COBOL Completions | 4 |
C Completions | 63 |
Total Stars | 130 |
% of votes with a positive feedback rating | 90% of 987 |
Total "Very Satisfied" Votes | 819 |
Total "Somewhat Satisfied" Votes | 142 |
Total "Not Satisfied" Votes | 26 |
Total Rank Assessments | 14 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |