Problem 54360. k partitions of an array of numbers having nearly equal sum
Solution Stats
Problem Comments
-
2 Comments
Pramit, there's an error in the test and the example: the matrix Y cannot be created as specified. Also, the solution is not unique. Couldn't you also have {[8 4 3 1 1 ], [7 5 4], [6 5 4 2]}, for example?
Indeed, a correct solution wouldn't even be accepted since the test cannot run properly. You're trying to create a matrix where rows don't have equal length. Matlab doesn't like that, but it doesn't even makes sense mathematically.
Also, as Chris said, as long as you have one solution, you have many of them, since you can do permutation of elements inside a row without changing the row sum. You probably have to have a way to include all possible solution (maybe just focus on the variance and the fact that there is a one to one correspondence between elements in the inputted vector and the outputted matrix?).
Problem Recent Solvers0
Suggested Problems
More from this Author4
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!