Brilliant, elegant and beautiful...truly pleasing to the eyes. This is what Cody is about. :). On a different note, Solution 1451618, with a size of 74, has an actual performance time of 4582 msec. While, this Solution has 8869 msec. But the problem states that 'Your score will be based on how quickly your script solves the problems in the test suite, rather than the typical Cody size.'. Any explanation on the actual scoring implementation, Bainhome?
Your comment just a chainsaw on my brain...:), first, solutions on this problem's size really baffles me a while,because someone with far more better code skill than me provide lots of code longer than I expected, I am confused about that. Secondly, when I saw your sol.'s size is slightly bigger(which is extremely rare), I have this sneaky smile on my face and close the page as quick as possible. But now I know this problem is about operational efficiency, not size. I'm not in the mood again...:)
But when we talk about operational efficiency, actual time that kinda stuff, I think Sol.1451618 is far more better. Vectoized code deal with large amount data "all at once", and for loop is "one by one", both of them have very different memory burden. and in this particular situation, i.e. very large number, factor... tradtional for loop has a significat advantage.
All above is purely assumption. Viewer discretion is advised.:)
Originally, this problem was scored by how quickly the code solved the problem. The Cody team changed the method of scoring at some point, so the method I used for setting the score proportional to the time spent solving the problem is no longer valid. There are a couple of other problems I have created that have the same issue.
Thanks James. Now I understand. :)
That's the fastest solution that I've found.
Make the vector [1 2 3 4 5 6 7 8 9 10]
35604 Solvers
Find all elements less than 0 or greater than 10 and replace them with NaN
13058 Solvers
Back to basics 22 - Rotate a matrix
763 Solvers
317 Solvers
The sum of individual numbers...
61 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!