Problem 44943. Calculate Amount of Cake Frosting
This problem is yummy! :-)
Simple & interesting.
The same as the surface area of a cylinder but without calculating the area of the bottom surface (circle) of the cylinder:
Having finished all 15 problem just to see what is the leading solution looks like. Then I realize smaller size doesn't mean the solution is better, often it is at the price of understand-ability.
Remember, in most cases, you write program for humans not for machines.
If you're considering trying to get your solution size down to 10 -- like the leading solution -- don't bother! They wrapped all their code in a regex statement so that the code size cannot be calculated anymore (the algorithm only sees the regex call, not what that regex actually does). ANY code you write like this is going to be of size 10 but is not going to be actually faster than the proper solution. Probably the exact opposite in fact.
Hey everybody! I may have a question about this exercise! I solved it, however, it comes to my mind one question. Furthermore, I solved using the area of the circle + the area of one of its sides, considering that is a cylinder. I do not know if there are other ways to solve it, so if you could share your way with me, I would be very grateful!
Many thanks in advance!
@Raul, the way you solved it is correct. The formula remains the same however people simplify it
Code in any programming language should always be readable with as little effort as possible. But regex are often hard to read - so don't look for brevity, but for clarity.
Why does this error (Unrecognized function or variable 'r') show up when I press run ?
@ Ali Raafat I have the same problem. It's unclear what exactly is going wrong when I do the 'run function' in the Test Suite
You should to use the 'r' in the Scratch Pad, and instead of the computer can't find the 'r' because you have never define the variable 'r' .
Solution CommentsShow comments
Problem Recent Solvers19105
Getting the indices from a vector
More from this Author13
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!