Problem 1873. Break it up! Break it up!
Test case p(300)=9253082936723604 exceeds the maximum integer that can be represented exactly as a double precision number (namely, 2^53=9007199254740992); the fact that some solutions work for this case is just luck.
Changed to p(299), which is <2^53. Thanks for the heads up.
Interestingly, p(299) had some issues as well. Changed again to p(199), which seems to be working OK.
If I ever want to learn something, I dial up a problem from James.
any input greater than 700 and this code will fail to compile in Cody's time limit
Test 1: function y = partitions(n) fails
isn't it suppose to be partitions(x)?
But this is just function definition.
Either partitions(x) or partitions(n) should not matter in the function definition.
Strange. The problem you were having had something to do with the error checking suite that was above the solutions. Your solution passed the error checks, but failed to actually work. Now that I have removed the error checks, your solution with partitions(n) passes. I may have to muck around with this a bit later on.
The problem was with the following line in the error checking:
st = sprintf('function y = partitions(x)\n%%%s', st);
This automatically changed the first line of your script to use partitions(x) instead of partitions(n). That was done to prevent folks from using the "function ans=blahblahblah(x)" technique when that still worked, That was just a holdover that happened to trip you up. Now that that line (and the rest of the suite0 has been removed, partitions(n) should work just fine.
@James oops! I was so careless that I didn't notice that single-line error checking (I thought your check was intended to forbid the usage of functions such as eval, str2num, etc, and thus I completely ignored that when I was solving the problem). Now I realized this is not a strange behavior or bug of Cody. Thanks for your clarification.
Problem Recent Solvers42
Renaming a field in a structure array
Reverse the elements of an array
Integer sequence - 2 : Kolakoski sequence
More from this Author80
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!