5 kyu
Stable Weight Arrangement
42 of 85docgunthrop
Description:
Here is a simple task. Take an array/tuple of unique positive integers, and two additional positive integers. Here's an example below:
arr = (3,5,7,1,6,8,2,4)
n = 3 # span length
q = 13 # weight threshold
Try to re-arrange arr
so that the sum of any n
consecutive values does not exceed q
.
solver(arr,n,q) ## one possible solution: (4,7,1,5,6,2,3,8)
Did you succeed? Great! Now teach a computer to do it.
Technical Details
- All test inputs will be valid
- All test cases will have
0
or more possible solutions - If a test case has no solution, return an empty array/tuple. Otherwise, return a valid solution
- Test constraints:
2 <= n <= 6
4 <= arr length < 12
n < arr length
- Every value in
arr
will be less thanq
11
fixed tests,25
random tests
- In JavaScript,
module
andrequire
are disabled - For JavaScript, use Node 10+
- For Python, use Python 3.6+
If you enjoyed this kata, be sure to check out my other katas
Arrays
Algorithms
Similar Kata:
Stats:
Created | Sep 3, 2019 |
Published | Sep 4, 2019 |
Warriors Trained | 734 |
Total Skips | 60 |
Total Code Submissions | 709 |
Total Times Completed | 85 |
Python Completions | 42 |
JavaScript Completions | 28 |
Go Completions | 22 |
Total Stars | 29 |
% of votes with a positive feedback rating | 94% of 33 |
Total "Very Satisfied" Votes | 29 |
Total "Somewhat Satisfied" Votes | 4 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 3 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 6 kyu |