Problem 2033. poll: would you like the regexp (?@cmd) functionality to be banned in Cody?
This problem is a poll (and a little bit of "white hat hacktivism" as well) regarding Cody users sentiment about the use of regexp to reduce the size/score of Cody solutions.
Your function should return one the following strings, reflecting your opinion on the question: would you like the regexp (?@cmd) functionality to be banned in Cody?
'no!' 'no' 'yes' 'yes!'
note1: the score of your solution will be 10 for 'no!' 20 for 'no', 30 for 'yes' and 40 for 'yes!' (so that a quick glance at the solution scores should give you an idea of the poll responses). If you want to solve this problem but do not have an opinion on this question -or if you are really interested in getting a low score-, just return an empty string (and you will get a 0 score).
note2: the question regards only the use of dynamic expressions of the form (?@cmd), it does not ask whether you would like regexp to be banned entirely)
Description:
The syntax:
regexp '' '(?@a=1)'
is equivalent to
eval 'a=1'
Hiding the functionality inside an eval or a regexp string allows Cody players to achieve a very low score regardless of the true complexity of the evaluated syntax. While the function eval is banned in Cody, the function regexp is too useful to be banned entirely, so it is not uncommon to see the leading solution to many Cody problems using this regexp trick.
There are, nevertheless, relatively simple ways to ban the use of dynamic expressions of the form (?@cmd), while still allowing the rest of the functionality of regexp. This poll asks your opinion about having such a ban in Cody.
Hacktivism:
This problem testsuite includes a little hack that temporally disallows the use of dynamic expressions of the form (?@cmd) in all of Cody (not just this problem), while allowing the rest of regexp functionality to work normally. And your vote decides whether to implement or not this temporal fix:
- If you answer 'Yes!' to this problem, one Cody server will stop accepting (?@cmd) solutions (it will return an error to any solution attempting to use dynamic expressions of the form (?@cmd))
- If you answer 'No!' to this problem, one Cody server will start accepting them again.
- all other answers will have no effect
There are typically around 5 Matlab servers running Cody solutions, and these are reset every hour approximately, so each "hack" will have a relatively short lifespan, and it will also only apply to a small proportion of all Cody solutions (but note that the effect is cumulative, answering ~5 'Yes!' questions is going to disallow the use of (?@cmd) dynamic expressions for all solutions sent to Cody for ~1 hour; answering ~5 'No!' questions is going to revert to the normal behavior).
This allows Cody users to not only express their opinions but also assert some form of 'decentralized' control over Cody behavior (which might, or might not be after all, a good idea). For now I am planning to leave this behavior only for a short time as a small 'hacktivism campaign', and revert this problem to being a pure poll (no longer affecting solutions to other Cody problems) after that. Feel free to take a look at the testsuite to explore how this is implemented (and please use responsibly), and/or leave your thoughts in the comments.
Solution Stats
Problem Comments
-
7 Comments
Another form of activism would be to weed out uses of regexp as in http://www.mathworks.com/matlabcentral/cody/problems/944-create-incremental-spiral-without-using-eval-or-feval/solutions/new.
This problem is also working correctly again after a few-weeks glitch. Rescored the last few votes to get those right.
Good
Is there a way to parse the code inside the regex and assign an appropriate size to it? That would seem like the most fair thing to do.
I believe this hack should be banned. It makes the code hard to read and creates a dummy small solution while not being the smallest (local minima that may not exist for the problem).
Throws error, resource referenced is inaccessible
Indeed, the test suite is (still) broken:
"Error using urlreadwrite_legacy The server did not find a resource to match this request."
Solution Comments
Show commentsProblem Recent Solvers180
Suggested Problems
-
7640 Solvers
-
Back to basics 25 - Valid variable names
323 Solvers
-
472 Solvers
-
308 Solvers
-
Find the index of the largest value in any vector X=[4,3,4,5,9,12,0,4.....5]
375 Solvers
More from this Author38
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!