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.
1st try :)
I did it
quick and easy start
function c = addo(a,b)
%I did the above, Why does it say it's wrong?
Why is this wrong here? I checked using matlab on my laptop and it works.
this is cool!
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:
So if your function is called 'sum' it wont be called by the test script.
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.
hello brian !
I'd like to know how your solution size is 9.
Can you please let me know how you did it ?
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
Error: Undefined function 'add_two_numbers' for input arguments of type 'double'
this is not a function?
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.
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.
Get the area codes from a list of phone numbers
Reverse the elements of an array
Add two numbers
Area of a Square
Find the longest sequence of 1's in a binary sequence.
The Goldbach Conjecture
Find the numeric mean of the prime numbers in a matrix.
What is the next step in Conway's Life?
Prime factor digits
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office