-
3 Comments
Does anyone know how the 'size' value is calculated? Is it related to the # of lines of code, or the complexity? Does anyone have any tips regarding how to reduce size? I keep writing high 'size' code...
"Cody uses a node-count calculation to determine the solution size based on the number of nodes in the parse tree. Think of size as code length." - via the Official Cody homepage.
You can reduce size by reducing no. of operations as well as no. of variables.
function y = plus_one(x)
y = x+1;
end
Function size = 12
function y = plus_one(x)
z = x;
y = z+1;
end
Function size = 16
For an example related to this question, instead of defining b, you can do x = A\[1;1].
You can also take a look on other user's solutions to get some more idea.
However, in the long run that is not the best practice you would want to learn. As we write complex code, defining variables clearly and explicitly helps understand the code better. I would say what you have done is a good example of a clean code.
That is a very helpful comment, @Dyuman Joshi.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!