Are there any code restrictions for Cody solutions?

Steve Eddins on 18 Oct 2025
Latest activity Reply by Dyuman Joshi on 31 Oct 2025

Are there any code restrictions for programming Cody solutions? I could not find anything mentioned at https://www.mathworks.com/matlabcentral/content/cody/about.html, other than toolbox functions not being available.
Chen Lin
Chen Lin on 28 Oct 2025
Hi Steve. Cody has some restricted functions, but we do not publish the list due to cheating prevention and security concerns.
Dyuman Joshi
Dyuman Joshi on 19 Oct 2025 (Edited on 19 Oct 2025)
Hello Steve,
Yes, there are code restrictions for submitting solutions, as many functions were being used to cheat/bypass the system.
Here's a list of the functions that I know about -
{'!','feval', 'eval', 'str2func',' system',' dos',' unix',' perl',' setenv',' path', 'deletefcn', 'rehash', 'assert', ''assignin','builtin', 'evalc', 'evalin', 'inline', 'run’}
These were particularly rampant in the earlier days of cody, atleast before I became active on Cody (2018).
Also, Cody had access to Toolboxes (and Simulink) earlier, however it has been removed/rescinded since quite awhile (I am unsure of the timeline). More info about the same on this thread - https://in.mathworks.com/matlabcentral/discussions/cody/862091-cody-where-s-the-modeling-and-simulation-challenge-group
Steve Eddins
Steve Eddins on 19 Oct 2025
Thanks, Dyuman,
I asked because I encountered a solution the other day using a str2num hack:
function ans = Sphere_radius(pts)
str2num '@(x)sqrt(sum(power([2*x, ones(4,1)]\dot(x,x,2),[2;2;2;1])))';
ans(pts)
end
Dyuman Joshi
Dyuman Joshi on 19 Oct 2025
Ah yes, this is also frequently used - mostly to reduce the code "size" as earlier points/score were based on one's solution size, but this is not inherently banned. Note that the solution you have encountered is from 2017.
Most likely it is not banned because it can also be used in a non-exploiting manner.
Many users do utilize a special test case to ban a few functions from being used as cheats, you can check out problems by Me or ChrisR.
Best to flag that solution (as you can see has been done by 2 users on that solution), which the moderators or the Cody team will take care of, sooner or later.
Please feel free to contact me about anything on Cody.
Steve Eddins
Steve Eddins on 19 Oct 2025
The Cody Help page still says that solution scores are based on solution size. Has that changed?
It's been years since I was last active on Cody, so my knowledge of the system is dated.
Dyuman Joshi
Dyuman Joshi on 20 Oct 2025
Yes, it has changed, see the attached screenshot image from the Help page which describes the current scoring system.
I'll ask the Cody team to update the description, removing the text related to the previous system.
Christian Schröder
Christian Schröder on 24 Oct 2025
Isn't the help page correct though? There are solution scores, which are indeed based on solution size, and player scores, which are not.
Dyuman Joshi
Dyuman Joshi on 24 Oct 2025
No, solution scores are not based on solution size anymore.
As you can see on the screenshot I have attached, first correct solution to a problem grants 10 points (and 1 bonus point for rating the problem).
Player score is the sum of solutions scores, problems (submitted) scores and groups scores.
Christian Schröder
Christian Schröder on 24 Oct 2025
Ah, I think we're simply using different terminology. What I mean by solution score is, in fact, a solution's size (in terms of nodes); the two coincide right now, but since there used to problems that assigned scores based on other metrics, I still mentally distinguish the two.
The number of points awarded to a player for solving a problem is of course not related to the solution's size, as you point out.
Dyuman Joshi
Dyuman Joshi on 23 Oct 2025
Can't seem to tag Eera here.
Anusha Sridharan
Anusha Sridharan on 30 Oct 2025
Thanks @Dyuman Joshi. This is fixed now, you should be able to tag Eera going forward.
Dyuman Joshi
Dyuman Joshi on 31 Oct 2025
Thank you, @Anusha Sridharan!