I am doing the math exercise by hand before starting to write an answer for the following programming exercise: Drying potatoes. The statement is:
All we eat is water and dry matter.
John bought potatoes: their weight is 100 kilograms. Potatoes contain water and dry matter.
The water content is 99 percent of the total weight. He thinks they are too wet and puts them in an oven - at low temperature - for them to lose some water.
At the output the water content is only 98%.
What is the total weight in kilograms (water content plus dry matter) coming out of the oven?
He finds 50 kilograms and he thinks he made a mistake: "So much weight lost for such a small change in water content!"
Can you help him?
Write function potatoes with
int parameter p0 - initial percent of water- int parameter w0 - initial weight - int parameter p1 - final percent of water -
potatoesshould return the final weight coming out of the oven w1 truncated as an int. Example:
potatoes(99, 100, 98) --> 50
I am trying to understand how can we solve by hand this exercise. I have tried the rule of 3:
- initial percentage of water -> initial weight
- final percentage of water -> x (final weight)
x = ( initial percentage of water - initial weight ) / final percentage of water;
x = 99 - 100 / 98 = -1 / 98 = -0,0102 (and it should be 50)...
Then I tried to use a linear equation as:
initial water percentage - final water percentage = initial weight - final weight (x); 99 - 98 = 100 - x; 99 - 98 - 100 = -x; x = 99 (and it should be 50)...
I have also observed the exercise's test cases where p0: initial water percentage, w0: initial weight, p1: final water percentage, w1: final weight (what we should be able to calculate)
- p0, w0, p1, w1
- 82, 127, 80, 114
- 93, 129, 91, 100
In addition I have also read:
- Solving linear equation
- What is a linear equation?
- Solve Linear Sytem of Equation for $u,v,w$
- https://www.purplemath.com/modules/systlin1.htm
- https://www.wtamu.edu/academic/anns/mps/math/mathlab/int_algebra/int_alg_tut7_lineq.htm
How could we calculate the final weight, knowing the initial water percentage, final water percentage, and initial weight‽??