6 kyu
Almost Even
1,705 of 4,021OverZealous
Description:
We need the ability to divide an unknown integer into a given number of even parts - or at least as even as they can be. The sum of the parts should be the original value, but each part should be an integer, and they should be as close as possible.
Complete the function so that it returns an array of integers representing the parts. If the input number is too small to split it into requested amount of parts, the additional parts should have value 0. Ignoring the order of the parts, there is only one valid solution for each input to your function!
Example:
splitInteger(20, 6) // returns [3, 3, 3, 3, 4, 4]
Inputs
The input to your function will always be valid for this kata.
Arrays
Algorithms
Stats:
Created | Dec 3, 2013 |
Published | Dec 3, 2013 |
Warriors Trained | 7390 |
Total Skips | 307 |
Total Code Submissions | 14572 |
Total Times Completed | 4021 |
JavaScript Completions | 1705 |
CoffeeScript Completions | 61 |
Haskell Completions | 327 |
Ruby Completions | 188 |
Python Completions | 1455 |
Scala Completions | 13 |
C++ Completions | 136 |
PHP Completions | 53 |
Crystal Completions | 10 |
Julia Completions | 9 |
C Completions | 224 |
Total Stars | 103 |
% of votes with a positive feedback rating | 92% of 590 |
Total "Very Satisfied" Votes | 507 |
Total "Somewhat Satisfied" Votes | 76 |
Total "Not Satisfied" Votes | 7 |