6 kyu
+1 Array
910 of 12,581khelmar
Description:
Given an array of integers of any length, return an array that has 1 added to the value represented by the array.
If the array is invalid (empty, or contains negative integers or integers with more than 1 digit), return nil
(or your language's equivalent).
Examples
Valid arrays
[4, 3, 2, 5]
would return[4, 3, 2, 6]
(4325 + 1 = 4326)[1, 2, 3, 9]
would return[1, 2, 4, 0]
(1239 + 1 = 1240)[9, 9, 9, 9]
would return[1, 0, 0, 0, 0]
(9999 + 1 = 10000)[0, 1, 3, 7]
would return[0, 1, 3, 8]
(0137 + 1 = 0138)
Invalid arrays
[]
is invalid because it is empty[1, -9]
is invalid because-9
is not a non-negative integer[1, 2, 33]
is invalid because33
is not a single-digit integer
Fundamentals
Arrays
Algorithms
Similar Kata:
Stats:
Created | Mar 27, 2015 |
Published | Mar 27, 2015 |
Warriors Trained | 27981 |
Total Skips | 3433 |
Total Code Submissions | 192063 |
Total Times Completed | 12581 |
C# Completions | 910 |
JavaScript Completions | 4283 |
Ruby Completions | 785 |
Python Completions | 6416 |
C Completions | 166 |
COBOL Completions | 3 |
Java Completions | 194 |
Haskell Completions | 12 |
Total Stars | 480 |
% of votes with a positive feedback rating | 89% of 1752 |
Total "Very Satisfied" Votes | 1455 |
Total "Somewhat Satisfied" Votes | 224 |
Total "Not Satisfied" Votes | 73 |
Total Rank Assessments | 235 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 2 kyu |
Lowest Assessed Rank | 8 kyu |