Cody

# Problem 1283. Points on a Sphere

Solution 1132121

Submitted on 2 Mar 2017
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 = 6; assert(isequal(surface_points(x),y_correct))

2   Fail
x = 1024; y_correct = 6; assert(isequal(surface_points(x),y_correct))

Error using bsxfun Requested 2049x2049x2049 (64.1GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information. Error in surface_points (line 3) bsxfun(@plus, bsxfun(@plus, ans, ans'), shiftdim(ans,-1))==r*r; Error in TestPoint2 (line 2) assert(isequal(surface_points(x),y_correct))

3   Fail
x = 7581; y_correct = 108270; assert(isequal(surface_points(x),y_correct))

Error using bsxfun Requested 15163x15163x15163 (25974.4GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information. Error in surface_points (line 3) bsxfun(@plus, bsxfun(@plus, ans, ans'), shiftdim(ans,-1))==r*r; Error in TestPoint3 (line 2) assert(isequal(surface_points(x),y_correct))

4   Fail
x = 450; y_correct = 2550; assert(isequal(surface_points(x),y_correct))

Error using bsxfun Requested 901x901x901 (5.4GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information. Error in surface_points (line 3) bsxfun(@plus, bsxfun(@plus, ans, ans'), shiftdim(ans,-1))==r*r; Error in TestPoint4 (line 2) assert(isequal(surface_points(x),y_correct))

5   Fail
x = 123456; y_correct = 19350; assert(isequal(surface_points(x),y_correct))

Error using bsxfun Requested 246913x246913 (454.2GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information. Error in surface_points (line 3) bsxfun(@plus, bsxfun(@plus, ans, ans'), shiftdim(ans,-1))==r*r; Error in TestPoint5 (line 2) assert(isequal(surface_points(x),y_correct))

6   Pass
x=ceil(rand*8); y_correct=[6 30 30 150 510 4590 4590 43470]; assert(isequal(surface_points(factorial(x+1)),y_correct(x)))