Given a and b, return the sum a+b in c.
A quick easy start! xD
I tried. But caught with error.
it is very easy to abuse the solution map by writing a correct solution with a lot of useless code before it. I tested this and got the solution map rescaled to absurdity (and I see I'm not the only one). Please correct this.
Easy start...
1st try :)
great
good job
nice q
nice
I did it
good
so fun!!!!!!
nice
Good one.
quick and easy start
nice
Easy Start
function c = addo(a,b)
c= a+b;
end
%I did the above, Why does it say it's wrong?
bingo!!!
good
Nice!
Why is this wrong here? I checked using matlab on my laptop and it works.
this is cool!
Good Job!
got it!
interesting
gud..
good one!
Good Job!
easy
nice
:D
This was a good problem/solution to start out on.
this is a bad solution
What is wrong with this solution?
the code is wrong because the function name should be 'add_two_numbers'.
In the test code the are evaluating:
assert(isequal(add_two_numbers(a,b),c_correct))
So if your function is called 'sum' it wont be called by the test script.
idk
Try writing out the equation you want to use, with 'c =' on the left, and 'a' and 'b' on the right. You don't need to define c =.., a =.., or b =.. in the function.
Good luck!
hello brian !
I'd like to know how your solution size is 9.
Can you please let me know how you did it ?
Thanks !
Why is this of size 9? The long string?
For the record, I don't recommend reading this, but here goes:
My solution is
function ans = add_two_numbers(varargin)
system 'echo "function ans = assert(~), true;" > ./assert.m';
It works by redefining the assert() function that the test suite uses to always return true. This strategy can be used to solve any problem. Many of the leading solutions to problems are hacks like this. It's actually quite fascinating to think of ways to "cheat" the system
Ah, that makes so much more sense! Thanks for explaining Brian.
Why is the following not accepted ?
add_two_numbers = @(x,y) x+y;
Solution size is also 9, but the solution is not recognized. Just wondering why, as it works in MATLAB.
@Danilo Maybe the website prevents anonymous functions.
This challenge was quite simple. Good for beginners.
self explainable code. thanks to cody team
really enjoy
Cool
Error: Undefined function 'add_two_numbers' for input arguments of type 'double'
this is not a function?
cheat.
Can you explain how does it work?
why this is working?
It was a system error. I re-scored the solution, and that did the right thing.
Har har
fast fourier transform should be fast anywhere,right?? why not here?xaxa Funny approach
Of course, c = a+b; is entirely correct, using the operator form for addition. plus(a,b) uses the function form.
642 Solvers
Back to basics 20 - singleton dimensions
222 Solvers
1293 Solvers
201 Solvers
228 Solvers