Maybe it’s a bad idea to code while hungry. Last night I decided to order pizza, and took my usual step of calculating the price per square inch for different size options (price/inch^2 usually decreases monotonically from smallest pizza to largest, but not always, and it’s often far from a linear progression). I stumbled on this code snippet from a site called “codinghax”:
it doesn’t account for the variable crust:non-crust ratio across different sizes of pizza
Then you’re probably failing to see the forest for the trees. This code calculates the number of square inches per dollar, whereas we want the reciprocal of that.
So that this is more than just complaining, here’s code that rectifies all of the above issues: