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

8 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
Solution Comments

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 Solvers14988
Suggested Problems

Return elements unique to either input
650 Solvers

438 Solvers

Generate a vector like 1,2,2,3,3,3,4,4,4,4
6622 Solvers

587 Solvers

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