6 kyu
Simple Fun #170: Sum Groups
376 of 1,088myjinxin2015
Description:
Task
Given an array of integers, sum consecutive even numbers and consecutive odd numbers. Repeat the process while it can be done and return the length of the final array.
Example
For arr = [2, 1, 2, 2, 6, 5, 0, 2, 0, 5, 5, 7, 7, 4, 3, 3, 9]
The result should be 6
.
[2, 1, 2, 2, 6, 5, 0, 2, 0, 5, 5, 7, 7, 4, 3, 3, 9] -->
2+2+6 0+2+0 5+5+7+7 3+3+9
[2, 1, 10, 5, 2, 24, 4, 15 ] -->
2+24+4
[2, 1, 10, 5, 30, 15 ]
The length of final array is 6
Input/Output
[input]
integer arrayarr
A non-empty array,
1 ≤ arr.length ≤ 1000
0 ≤ arr[i] ≤ 1000
[output]
an integerThe length of the final array
Arrays
Algorithms
Lists
Data Structures
Similar Kata:
Stats:
Created | Feb 27, 2017 |
Published | Feb 27, 2017 |
Warriors Trained | 2643 |
Total Skips | 99 |
Total Code Submissions | 5825 |
Total Times Completed | 1088 |
JavaScript Completions | 314 |
Ruby Completions | 64 |
Crystal Completions | 7 |
Python Completions | 376 |
Java Completions | 242 |
C# Completions | 70 |
Haskell Completions | 35 |
λ Calculus Completions | 8 |
Rust Completions | 34 |
Go Completions | 27 |
COBOL Completions | 7 |
Factor Completions | 8 |
Total Stars | 64 |
% of votes with a positive feedback rating | 93% of 267 |
Total "Very Satisfied" Votes | 240 |
Total "Somewhat Satisfied" Votes | 19 |
Total "Not Satisfied" Votes | 8 |
Total Rank Assessments | 11 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |