php icon indicating copy to clipboard operation
php copied to clipboard

Formula for calculateCheeseCubeCoverage in pizza-pi is misleading

Open neilmayhew opened this issue 1 year ago • 2 comments

The formula given is

pizzas = (cheese_dimension^3) / (thickness * PI * diameter)

It should be:

pizzas = (cheese_dimension^3) / (thickness * PI * (diameter/2)^2)

The formula given produces wildly incorrect results. However, if it's changed now it will invalidate all of the existing community solutions. Instead, I suggest a note be added to the instructions explaining that the formula needs to be used as-is rather than being corrected by the programmer.

I think it would also be helpful for beginners if the formula used ** rather than ^, since ^ is a valid operator in PHP but produces very unexpected results that are very hard to figure out if you don't already know PHP. Alternatively, the formula could use a superscript-3 Unicode character:

pizzas = (cheese_dimension³) / (thickness * PI * diameter)

neilmayhew avatar Feb 13 '24 18:02 neilmayhew

@neilmayhew Even if the use of PI in that equation resembles calculating the area of the pizza, the exercise does not make that claim. "Lilly calculated an equation to determine [...] of some diameter (d)" in my eyes clearly enough says, that the formula is made up by Lilly.

Regarding the choice of characters: I will re-write the exercise soon and focus it on the use of arithmetic operators. That means, I will step away from that formula and use ³ as you suggest.

Edit: I confused the goals outlined in #578 .

mk-mxp avatar Feb 14 '24 22:02 mk-mxp

Even if the use of PI in that equation resembles calculating the area of the pizza, the exercise does not make that claim. "Lilly calculated an equation to determine [...] of some diameter (d)" in my eyes clearly enough says, that the formula is made up by Lilly.

Technically, you're correct, but unless someone is playing very close attention they could easily miss this (as I did) and have a very hard time understanding what they did wrong (despite the fact that I've been programming for many years). It seemed natural to me to "fix" the formula, thinking that it was a typo. The instructions say the function should "return the number of pizzas that can be made" and so I tried to do that.

Perhaps these slight changes to the wording would help:

Lilly decided to use the following formula to determine …

  • And uses Lilly's formula to return the number of pizzas that can be made while rounding down.

neilmayhew avatar Feb 14 '24 23:02 neilmayhew