Please consider that the problem is related to the Linear Diophantine
Equations. For this sample we have a set of the simultaneous equations:

{ g/20 + 5*b + 1*c = 100

{ g + b + c = 100

{ g, b, c are positive integer values and in the range of [ 1..98 ]


 Overall, for these questions we have *N* variables, and *N – 1 *equations
and are solved through Diophantine Equations approach.


By solving the equations for this sample, we have:

g = 80, b = 19, c = 1. Therefore, we should pay:

4$ for 80 Goats, 95$ for 19 Bulls, and 1$ for 1 Cow.

-- Amir

On Fri, Aug 10, 2012 at 6:22 AM, Luke Pebody <[email protected]> wrote:

> Python:
> print [(c,b,g) for c in xrange (101) for b in xrange(101) for g in
> xrange(0,101,20) if c+b+g == 100 and c+5*b+(g/20) == 100]
> On Aug 10, 2012 8:01 AM, "Bonethug" <[email protected]> wrote:
>
>> You have $100. You need to buy cows, bulls and goats which sell at the
>> following rate.
>> $1 = 1 Cow
>> $5 = 1 Bull
>> $1 = 20 Goats
>> How will you purchase these animals so that you spend your $100 and you
>> have 100 animals which includes the cows, bulls and goats.
>> A pretty tough question for more google code community, I need help,
>> Thanks and Regards,
>> Bonethug
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Code Jam" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/google-code/-/Gg_LTqD8YdEJ.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to