MATLAB: How are ninja solutions even possible in Cody

codyMATLAB

In a previous Q & A, Jan Simon pointed to Cody: Sum 1:2^n. The current leading solution to that problem has node-count (or more simply, "length") 10. Apparently, 10 is the minimal length (per the official length-function on File Exchange) of any function taking input & generating output:
function y = test_cody_solution(x)
y = x;
end
Per Cody instruction examples, additional computation within a function definition increases the solution length. For example, both of the following functions have length 12:
function y = test_cody_solution(x)
y = [x];
end
function y = test_cody_solution(x)
y = x+1;
end
My question is: what kinds of ninja-style coding idioms even exist in MATLAB which actually perform definite computation but at the same time do not increase the node-count above 10? I'm not able to imagine what could be going on in order for someone to solve a given non-trivial Cody puzzle in length 10 or 11? IOW, without respect to any particular Cody problem, could someone please give an example of a non-trivial function which somehow comes in at or just above the absolute lower bound? Any explanation of the magic would be appreciated as well.
Thanks, Brad

Best Answer

Not sure if I am using super-powers to see the leading solution that you pointed to but his is what was leading:
function y = sum_int(x)
regexp '' '(?@y=sum(1:2^x);)'
end
So this is the Ninja solution to that Cody problem
I would not spend a whole lot of mental effort on figuring out this "best" solutions to these Cody problems. The scoring encourages really arcane solutions like this. I take pride in having the "worst" score on most of the problems I am involved with. I will take long, readable code every time.
Related Question