Tuesday, July 08, 2008

My math is not that rusty yet =)

My math and problem analytic skill are not that rusty yet. This is proven by what happened today. So, in short, Chatrin sent an email about a math problem.
Egg $0.10
Chicken $6
Watermelon $3

Question:
How many of above items to get the total 100 items of $100 dollar?
OR If from software point of view, how to calculate it by algorithm?
If you are not interested in knowing how it is solved, it doesn't matter. The answer is
70 eggs, 10 chicken, and 1 watermelon

This is the algorithm that I derived. I eliminate the basic steps so you can find it out yourselves.
For w=0 till w=31
.... c=(900-29w)/59
.... if c is a positive integer then
.... .... e = 100 - c - w
.... ....if e is a positive integer, then
.... .... .... return value of e, c, w (solved)
.... .... .... endif
.... endif
end for
return false (cannot be solved)
w = watermelons, e = eggs, c = chicken.

My math is not that rusty yet, hahaha....

Labels: ,


This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]