Problem 801. Construct an index vector from two input vectors in vectorized fashion
Solution Stats
Problem Comments

9 Comments
Please do not check for the occurance of "for" in general, because "UniFORmOutput" has nothing to do with looping ;)
Your predefined function signature has only one parameter, altough two were submitted. Same problem without the "for" restriction: http://www.mathworks.com/matlabcentral/cody/problems/555lowhighlowhighturnaroundcreateasubindicesvector
This is an excellent problem.
I agree with Dirk. Change your regexp to check for instances of eval, for, and while that are not preceded or followed by additional letters.
give me a hint, should we use a specific function here?
Tip: replace UniformOutput with uni.
Actually arrayfun should also be outlawed, as that simply hides the loop at a performance cost. I haven't seen a vectorized solution yet, only recursions and implicit loops (and the usual cheatsubmissions).
If you want a more robust cheatdetection you should have a separate test which runs as first test. That one should not call the submission to avoid it overwriting functions like fileread and assert.
I hate problems that disallow basic programming skills. Unless you know the one specific function that probably just does this for free, you have no idea how to solve it. And from the sounds of it, there isn't a vectorized solution anyway.
I wish you could peek at the functions in the solutions to see what people used.
Rik, your suggestion for a separate test case for cheat detection has been implemented. And ideally, arrayfun should be banned as well for the reason you have stated, but since author has not chosen to, I will refrain from doing so as well.
Also, I can say that the reference solution is a vectorized solution.
Brandon, the idea of such problems is to allow you to brainstorm through different methods, approaches and concepts, and in doing so, learn new programming techniques and/or functions. Without the restrictions, the problem would be extremely easy. And there are already problems with the same theme without any restrictions on Cody, you can explore and find them easily.
As I stated above, I can assure your there is atleast one vectorized solution.
Solution Comments
Show commentsProblem Recent Solvers387
Suggested Problems

1238 Solvers

Remove the two elements next to NaN value
648 Solvers

Matrix with different incremental runs
499 Solvers

String Array Basics, Part 1: Convert Cell Array to String Array; No Missing Values
1497 Solvers

8754 Solvers
More from this Author3
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!