Problem 44943. Calculate Amount of Cake Frosting
Solution Stats
Problem Comments

15 Comments
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:
Original: A=2πrh+2πr2
Modified: A=2πrh+πr2
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 understandability.
Remember, in most cases, you write program for humans not for machines.
Nice
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' .
I am having a problem trying to output all 3 different answers in this problem. I can get it to output the right answers as a vector but that isn't what it is asking and I am confused
I used the cylinder surface area formula: 2*pi*r(r+h)
am I using the wrong formula?
@Maya Ben Yacov It's the right formula in principle, but keep in mind that the bottom of the cake does not get frosting.
Solution Comments
Show commentsProblem Recent Solvers22136
Suggested Problems

Find the alphabetic word product
3186 Solvers

1088 Solvers

6383 Solvers

871 Solvers

321 Solvers
More from this Author13
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!