Problem 963. We love vectorized solutions. Problem 1 : remove the row average.
Solution Stats
Problem Comments
-
9 Comments
Please modify the fourth test suite so it reports the duration when the assert fails. My tests say I should pass but Cody is exceeding the time. The method to output information on a failed assert is: assert(duration<2,sprintf('Time used %2.3f\n',duration));
thx
The other thing to do is to remove the ";" from the duration=toc(timer) line. This will allow everyone to see how fast the successful routines take to execute. My self-test times are < 500msec but I don't know Cody's speed. thx
Thanks Richard, your suggestions have been implemented.
I am hoping to stimulate a change to cody where some problems (or all) problems are graded on performance not size. A low size often means an unreadable solution, and people have found enough tricks to make size an irrelevance, anyway.
As per Solution 1539945, the Test Suite has been corrupted for me. For me the first line of the Test Suite appears to read "%%x = [ 0 1 ; 2 3 ] ;", and the correct inputs are not supplied. This may be the same Cody bug that previously affected Problem 970 (& perhaps Problem 1319) and still affects Problem 753.
Timing aspect is neat.
The solution with for is able to solve this problem currently within time. When requesting performance, you should measure the time dynamically, or else you will be forced to adjust the threshold as the years go by and computers evolve.
You should make the timing test dynamic. The current optimally vectorized solution is about 7 or 8 times faster than the default looped solution. You could add a test that confirms at least a 75% time reduction.
This was pretty easy...
Solution Comments
Show commentsProblem Recent Solvers773
Suggested Problems
-
Find state names that start with the letter N
1100 Solvers
-
627 Solvers
-
Celsius to Fahrenheit converter
571 Solvers
-
Convert a Cell Array into an Array
1280 Solvers
-
6857 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!