This solution is outdated. To rescore this solution, sign in.
-
10 Comments
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 copy-pastes 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 black-holes 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......
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!