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.
Arrange Vector in descending order
peta to nano (x-ray)
Rounding off numbers to n decimals
Sums of Distinct Powers
How Far Can You Throw Something?
A matrix of introverts
There are 10 types of people in the world
Find the treasures in MATLAB Central and discover how the community can help you!
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