How does this help anyone? This has nothing to do with learning better MATLAB code and doesn't even run.
This is not useful. What a waste of time...!
Can you please explain how that solution work? thanks
On the positive side of it, I'm very happy not to see people blindly copy pasting the above solution for every problem. This shows that the majority of the participants actually understand why we're all doing this. BTW, smart workaround!
Hi Ali, what is the workaround your speaking of? I am very confused by this solution, but I would like to understand it.
Even though it doesn't solve the actual problem, I thought this solution was clever enough (without too many copypastes by others, or maybe MathWorks fixed this workaround since then) to merit explaining it.
For those wondering, the line of code within the is_it_odd function does the following:
1. It does a system call to echo a single line to the standard i/o (a virtual place where programs can share/exchange their inputs and outputs).
2. The single line is in the form of a Matlab inline function, named assert(), that blackholes any inputs and always outputs the boolean 'true.'
3. The system call takes this single inline Matlab function and replaces the contents of assert.m (of whatever structure/setup for Matlab interpretation that Cody uses) with that single line.
4. Cody checks solutions with a series of assert(isequal(stuff,things)) calls, which now always evaluate to be true in this particular instance, as opposed to actually comparing if 'stuff' and 'things' are the same.
good job
Nice work on a creative solution that has the "smallest size" per Cody's grading criteria. However, as a beginner to MATLAB, I don't see why I would want to write something this long/complex when there are much shorter solutions (perhaps not per Cody's criteria but they use less characters). I guess it's all about winning the contest.
want to how can be size 9
9...............how can you do that......
Test  Status  Code Input and Output 

1  Pass 
%%
n = 1;
ans_correct = true;
assert(isequal(is_it_odd(n),ans_correct))
[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function
to avoid a potential name conflict.]
ans =
1

2  Pass 
%%
n = 2;
ans_correct = false;
assert(isequal(is_it_odd(n),ans_correct))
[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function
to avoid a potential name conflict.]
ans =
1

3  Pass 
%%
n = 28;
ans_correct = false;
assert(isequal(is_it_odd(n),ans_correct))
[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function
to avoid a potential name conflict.]
ans =
1

4  Pass 
%%
n = 453;
ans_correct = true;
assert(isequal(is_it_odd(n),ans_correct))
[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function
to avoid a potential name conflict.]
ans =
1

5  Pass 
%%
n = 17;
ans_correct = true;
assert(isequal(is_it_odd(n),ans_correct))
[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function
to avoid a potential name conflict.]
ans =
1

6  Pass 
%%
n = 16;
ans_correct = false;
assert(isequal(is_it_odd(n),ans_correct))
[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function
to avoid a potential name conflict.]
ans =
1

348 Solvers
Back to basics 4  Search Path
277 Solvers
Output any real number that is neither positive nor negative
241 Solvers
Determine the number of odd integers in a vector
312 Solvers
Side of an equilateral triangle
1423 Solvers