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
-
1 Comment
Btw, I've sent this solution before submitting the default solution. Since this was pretty fast, I guessed that the default would work too.
-
1 Comment
How can this be the leading "solution"? I see that it passes the tests but it is not a solution.
-
1 Comment
Not sure why this is not passing, I've tested time and it completes under 1 second... Anyone have any ideas?
I'm getting the error "While evaluating the solution, the server encountered an error caused by temporary unavailability of MATLAB Service. Wait a few minutes for the MATLAB Service to return, and then rescore." but have been able to submit other answers so I assuming it is not passing?
-
1 Comment
By vectorized he means y=[..... ] ? Or is it just bugged so this is futile?
-
3 Comments
There is a serious problem with the Test Suite for this submission to pass!!! —DIV
26–27 May 2018: 2L. Time used = 1.115 seconds in last test case.
See Problem 44655. https://www.mathworks.com/matlabcentral/cody/problems/44655
-
1 Comment
Consistently, reproducibly getting the following error, "While evaluating the solution, the server encountered an error caused by temporary unavailability of MATLAB Service. Wait a few minutes for the MATLAB Service to return, and then rescore." only for certain array assignments to variable y. See submission code. —DIV
-
1 Comment
Test Suite has been corrupted. Output from my code is merely echoing the input in each case, which doesn't match the intended input.
-
1 Comment
20 Sep 2017: 2L. Time used = 2.040 seconds in last test case.
-
1 Comment
tic toc hack :)
-
1 Comment
The MATLAB service for this has been unavailable for the past couple of days.
-
1 Comment
03 Mar 2017: 2L. Time used = 2.341 seconds in last test case.
-
1 Comment
31 Mar 2016: 2L. Time used = 1.436 seconds in last test case.
-
1 Comment
17 Apr 2015: 2L. Time used = 3.099 seconds in last test case.
-
1 Comment
09 Jul 2013 : 2L. Time used = 4.112 seconds in last test case.
-
1 Comment
29 Dec 2012: 2L. Time used = 4.740 seconds in last test case.
-
1 Comment
6 Oct 2012: 1L. Time used = 1.226 seconds in last test case.
-
3 Comments
Fuzzy Logic Toolbox is required for this functioon?
I have it on my System Identification toolbox. There is no clear rule what toolbox functions are admissible. If it works, I guess it is allowed.
Another instance of Toolbox use from the initial time period of Cody.
-
1 Comment
02 Oct 2012: 0L. Time used = 0.2666 seconds in last test case.
-
1 Comment
Thanks, I was unaware of 'detrend'.
-
1 Comment
How come this fails the first time? Are you just on the limits of the time threshold?
-
1 Comment
This is almost exactly the same as my 'reference' solution. But later some other people came up with cleaner solutions...
Problem Recent Solvers761
Suggested Problems
-
Given two arrays, find the maximum overlap
1086 Solvers
-
945 Solvers
-
1180 Solvers
-
363 Solvers
-
Sum the numbers on the main diagonal
536 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!