The problem does not limit the array to a single row. Add a few cases of multiple rows or define as single row.
x = [1:10 NaN];
y_correct = [ 1:10 10];
assert(isequal(replace_nans(x),y_correct))
c =
1 2 3 4 5 6 7 8 9 10 NaN
Output argument "y" (and maybe others) not assigned during call to "replace_nans".
Error in Test4 (line 3)
assert(isequal(replace_nans(x),y_correct))
why wont this pass?
Not really a solution, more like a "white flag" regarding this direction.
hint: recursion
big size ...!
I just realized that you can cause inconvenience to some players by posting cody problems like "Hello Everyone!!!". I did create that cody problem just to say Hi to my fellow cody players. It was not intended to waste your time or cause inconvenience. My apologies for whoever deleted that problem.
I am sure it was deleted by mistake, there are plenty of similar Cody problems (think Chuck Norris, indian mathematicians, smartest matlab programmers, and a long etc...) Perhaps Ned can put it back up?
Thanks for the reply sir.
Strange...those assertions pass on my computer
For the second test it gives: [0 0 1 2 2 2 17 3 -4] instead of [0 1 2 2 2 17 3 -4 -4]
Nice, it is very intuitive that a solution with this function is possible but still hard to find.
It's like a lesson. logical indices don't have to be full size! And for will apparently loop through a vector! Thanks!
Bonus! Vector doesn't have to be monotonic!
2486 Solvers
4325 Solvers
Generate a vector like 1,2,2,3,3,3,4,4,4,4
3609 Solvers
238 Solvers
Solve a System of Linear Equations
3443 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!