Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 270969

Submitted on 2 Jul 2013 by Clemens Giegerich

Correct

25Size
Leading solution size is 15.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
x = 10000;
y_correct = x;
z = simplepartition(x); zL = length(z);
assert(isequal(sum(unique(z)),y_correct) && zL >= ceil(log2(x)/2))
x = 40190;
y_correct = x;
z = simplepartition(x); zL = length(z);
assert(isequal(sum(unique(z)),y_correct) && zL >= ceil(log2(x)/2))
x = 149;
y_correct = x;
z = simplepartition(x); zL = length(z);
assert(isequal(sum(unique(z)),y_correct) && zL >= ceil(log2(x)/2))