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.
This is the algorithm that I derived. I eliminate the basic steps so you can find it out yourselves.
My math is not that rusty yet, hahaha....
Egg $0.10If you are not interested in knowing how it is solved, it doesn't matter. The answer is
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?
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=31w = watermelons, e = eggs, c = chicken.
.... 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)
My math is not that rusty yet, hahaha....
Labels: game theory, mathematics
Comments:
<< Home
Eggs will be in 10s since we do not want cents (cents will not add up with $6 chickens and $3 watermelons to make $100)
e=10
while e <= 100
for c=1; c<=(100-e-1); c++
for w=1; w<=(100-e-c); w++
if (c+w==(100-e)) &&
(6c+3w==(100-0.1e)) then
finish
e=e+10
loop
e=10
while e <= 100
for c=1; c<=(100-e-1); c++
for w=1; w<=(100-e-c); w++
if (c+w==(100-e)) &&
(6c+3w==(100-0.1e)) then
finish
e=e+10
loop
Diana,
I screwed up...
The total of the items is not 100. After flying so much, your maths is not that rusty yet =).
Felrick,
Yeah... way to go! A cool optimization you did there. Used to do that when I was still active in Topcoder community.
Post a Comment
I screwed up...
The total of the items is not 100. After flying so much, your maths is not that rusty yet =).
Felrick,
Yeah... way to go! A cool optimization you did there. Used to do that when I was still active in Topcoder community.
Subscribe to Post Comments [Atom]
<< Home
Subscribe to Comments [Atom]

