Cody

# Problem 1873. Break it up! Break it up!

Solution 1932397

Submitted on 12 Sep 2019
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
x = 1;y_correct = 1;assert(isequal(partitions(x),y_correct))

2   Fail
x = 5;y_correct = 7;assert(isequal(partitions(x),y_correct))

Assertion failed.

3   Fail
x = 50;y_correct = 204226;assert(isequal(partitions(x),y_correct))

Error using perms (line 23) Maximum variable size allowed by the program is exceeded. Error in partitions (line 2) y = perms(cumsum(ones(1,x))); Error in Test3 (line 1) x = 50;y_correct = 204226;assert(isequal(partitions(x),y_correct))

4   Fail
assert(isequal(partitions(partitions(partitions(partitions(5)))),476715857290));

Error using ones Size inputs must be scalar. Error in partitions (line 2) y = perms(cumsum(ones(1,x))); Error in Test4 (line 1) assert(isequal(partitions(partitions(partitions(partitions(5)))),476715857290));

5   Fail
assert(isequal(partitions(partitions(partitions(6))),526823));

Error using ones Size inputs must be scalar. Error in partitions (line 2) y = perms(cumsum(ones(1,x))); Error in Test5 (line 1) assert(isequal(partitions(partitions(partitions(6))),526823));

6   Fail
assert(isequal(partitions(partitions(12)),10619863));

Out of memory. Type "help memory" for your options. Error in perms>permsr (line 49) P = zeros(nn*m,nn); Error in perms (line 31) P = permsr(n); Error in partitions (line 2) y = perms(cumsum(ones(1,x))); Error in Test6 (line 1) assert(isequal(partitions(partitions(12)),10619863));

7   Fail
assert(isequal(partitions(199),3646072432125))

Error using perms (line 23) Maximum variable size allowed by the program is exceeded. Error in partitions (line 2) y = perms(cumsum(ones(1,x))); Error in Test7 (line 1) assert(isequal(partitions(199),3646072432125))

8   Fail
P=arrayfun(@(x) partitions(x),10:10:100); y_correct=[42 627 5604 37338 204226 966467 4087968 15796476 56634173 190569292]; assert(all(isequal(P,y_correct)))

Error using arrayfun Non-scalar in Uniform output, at index 1, output 1. Set 'UniformOutput' to false. Error in Test8 (line 1) P=arrayfun(@(x) partitions(x),10:10:100);