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

10 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 ?
Solution Comments

1 Comment
Unless the cake isn't floating in the freezer receiving frost from all sides, then the base won't catch the cold if it is placed usually.

1 Comment
At first i wrote the code like the bottom of the cake needed to be frosted

1 Comment
I am confused because I don't think that this answer is the surface area of a cylinder.

1 Comment
easy question

1 Comment
easy

2 Comments
This Problem has some info missing they did not specified for which shape we have to find surface area, I request the Creator to rectify it.
Where would you frost a cake? Give it a thought.

2 Comments
surely wrapping all the code into a regular expression, which hides it from the code size calculation algorithm of Cody, is cheating... This way you can get a size of 10 on nearly any problem. Thanks for messing up the solution chart for the rest of us...
Thanks to @SvenStahs, I now know why I can't achieve the minimum size. Thanks bud! And you guys need to fix this.. :(

2 Comments
unbelieveble
Good problem

1 Comment
Interesting

3 Comments
the ans is 0, because the cake will be eaten.
I need help.I just couldn't use the expressions correctly
haha

3 Comments
that's good
thanks
thanks

1 Comment
calculating surface area except the base area

1 Comment
easy

1 Comment
I do not think this exercise is correct. As one should not put frosting below the cake, the area of the cake to put frost on is the area of the circle on top of it plus the area of the "bent" rectangle on its sides. Thus:
function SA = func_frosting2(r,h)
ARectangle = pi*r*h;
ACircle = pi*r^2;
SA = ARectangle + ACircle;
I think the current solution is misleading

1 Comment
simple and fun.

1 Comment
just tricky one.
Problem Recent Solvers17773
Suggested Problems

The Goldbach Conjecture, Part 2
1911 Solvers

1299 Solvers

given 3 sides, find area of this triangle
771 Solvers

383 Solvers

765 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!