aditee sharma

Ranch Hand

Posts: 182

posted 7 years ago

Given that a Goat costs 0.50 Paise(or cents), a Horse costs 10 Rs.(or $) and a Cow costs 3 Rs. and you have 100 Rs. in hand.

How many animals of each category would you buy so that that total no. of animals is 100 ?

How many animals of each category would you buy so that that total no. of animals is 100 ?

posted 7 years ago

Okay I'm really bad at these kind of questions, but I'll buy 80 goats (cost 40Rs/$) and 30 Cows (cost 60Rs/$), I'm sure this is wrong as I didn't buy any horse but the question didn't say we have to buy at least one of each type.

There's a question that someone asked me when I was around 5-6yrs old, and I couldn't find the answer, but actually the question is funny, here it is

"3 friends went to a shop to buy a drink for themselves from their regular shop, the owner of the shop was not there and a staff gave them the drink for 30Rs/$. When the owner came, he said the staff that since they are regulars, so he gives them discount of 5Rs/$. So he sends the staff to their home to return the 5Rs/$. The Staff in the way takes 2Rs/$ for himself and returned them the remaining 3Rs/$ and they each took 1Re/$ each. So now they all paid 9Rs/$ each. That sums up to 27Rs/$ and 2Rs/$ are with the staff, so 27+2 = 29Rs/$, then where is the remaining 1Re/$??"

(Don't come to me asking for a dollar for 1 rupee, when I say Rs/$, ignore the exchange rates for the currencies)...

There's a question that someone asked me when I was around 5-6yrs old, and I couldn't find the answer, but actually the question is funny, here it is

"3 friends went to a shop to buy a drink for themselves from their regular shop, the owner of the shop was not there and a staff gave them the drink for 30Rs/$. When the owner came, he said the staff that since they are regulars, so he gives them discount of 5Rs/$. So he sends the staff to their home to return the 5Rs/$. The Staff in the way takes 2Rs/$ for himself and returned them the remaining 3Rs/$ and they each took 1Re/$ each. So now they all paid 9Rs/$ each. That sums up to 27Rs/$ and 2Rs/$ are with the staff, so 27+2 = 29Rs/$, then where is the remaining 1Re/$??"

(Don't come to me asking for a dollar for 1 rupee, when I say Rs/$, ignore the exchange rates for the currencies)...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links

Ryan McGuire

Ranch Hand

Posts: 1113

7

posted 7 years ago

ASSUMPTIONS:

- This is merely a math puzzle, and we're not counting me as an animal.

- We don't consider that I have to ride away a horse or anything like that.

- I'm trying to spend exactly 100 Rs. Heck, I could buy just 100 Goats and keep the other 50 Rs.

As a starting point, I could buy just 10 horses. From that "state" I can trade in 3 horses for 10 cows, for a net gain of seven animals. Similarly, I could trade in 1 horse for 20 goats, gaining 19 animals. Lastly, I could trade a Cow for 6 goats, gaining 5 animals.

Initially, I'm short 90 animals. I think I'll trade in 5 of my initial 10 horses for 19*5=95 additional animals. Oops, that put me 5 animals over. I'll trade 6 goats for 1 cow, putting me right at 100 animals.

5 Horse -> 50 Rs.

1 Cow -> 3 Rs.

94 Goats -> 47 Rs.

TOTAL: 100 animals for 100 Rs.

Final Answer.

aditee sharma wrote:Given that a Goat costs 0.50 Paise(or cents), a Horse costs 10 Rs.(or $) and a Cow costs 3 Rs. and you have 100 Rs. in hand.

How many animals of each category would you buy so that that total no. of animals is 100 ?

ASSUMPTIONS:

- This is merely a math puzzle, and we're not counting me as an animal.

- We don't consider that I have to ride away a horse or anything like that.

- I'm trying to spend exactly 100 Rs. Heck, I could buy just 100 Goats and keep the other 50 Rs.

As a starting point, I could buy just 10 horses. From that "state" I can trade in 3 horses for 10 cows, for a net gain of seven animals. Similarly, I could trade in 1 horse for 20 goats, gaining 19 animals. Lastly, I could trade a Cow for 6 goats, gaining 5 animals.

Initially, I'm short 90 animals. I think I'll trade in 5 of my initial 10 horses for 19*5=95 additional animals. Oops, that put me 5 animals over. I'll trade 6 goats for 1 cow, putting me right at 100 animals.

5 Horse -> 50 Rs.

1 Cow -> 3 Rs.

94 Goats -> 47 Rs.

TOTAL: 100 animals for 100 Rs.

Final Answer.

posted 7 years ago

I've heard Ankit's puzzle with a hotel room and dollars, but the numbers are exactly the same. Interesting.

The answer is that 27 + 2 = 29 not 30, is the wrong way of looking at it. It's deceptive because it uses numbers from the puzzle, but in an incorrect way. The men paid 30 originally, but 3 is returned to them. So the men actually paid 27, of which 25 went to the hotel/bar, and 2 went into the bellboy/bartender's pocket. So it's 27 - 2 = 25. No missing dollar, or whatever the prevailing currency is.

The answer is that 27 + 2 = 29 not 30, is the wrong way of looking at it. It's deceptive because it uses numbers from the puzzle, but in an incorrect way. The men paid 30 originally, but 3 is returned to them. So the men actually paid 27, of which 25 went to the hotel/bar, and 2 went into the bellboy/bartender's pocket. So it's 27 - 2 = 25. No missing dollar, or whatever the prevailing currency is.

posted 7 years ago

You have these two equations specified:

x/2 + 10y + 3z = 100

x + y + z = 100

Combining the two and eliminating x you have this:

19y + 5z = 100

Now there's an implied requirement that x, y, and z must be non-negative integers. So that means that y must be divisible by 5; y could be 0, or it could be 5, but it can't be 10 because then z would be negative. Once you have a value from y you can compute z and then x.

So there are two solutions. One is Ankit's (after correcting the typo from 30 cows to 20) and the other one is Ryan's.

x/2 + 10y + 3z = 100

x + y + z = 100

Combining the two and eliminating x you have this:

19y + 5z = 100

Now there's an implied requirement that x, y, and z must be non-negative integers. So that means that y must be divisible by 5; y could be 0, or it could be 5, but it can't be 10 because then z would be negative. Once you have a value from y you can compute z and then x.

So there are two solutions. One is Ankit's (after correcting the typo from 30 cows to 20) and the other one is Ryan's.

ankur rathi

Ranch Hand

Posts: 3830

Mike Simmons

Ranch Hand

Posts: 3090

14

posted 7 years ago

I think you're interpreting it wrong. If someone asks "how many should I buy?" then "zero" is a perfectly acceptable answer. A negative number would (usually) be unacceptable, and a non-integer value would be unacceptable for some things (animals, cars, books, computers, for example) but perfectly acceptable for others (pounds of grain, or grams of pure gold, for example). But nothing in the question implies that you have to buy a nonzero quantity of each animal.

ankur rathi wrote:aditee sharma wrote:How many animals ofeachcategory would you buy so that that total no. of animals is 100 ?

I think the question did say you have to buy each type of animal. Or am I interpreting it wrong!

I think you're interpreting it wrong. If someone asks "how many should I buy?" then "zero" is a perfectly acceptable answer. A negative number would (usually) be unacceptable, and a non-integer value would be unacceptable for some things (animals, cars, books, computers, for example) but perfectly acceptable for others (pounds of grain, or grams of pure gold, for example). But nothing in the question implies that you have to buy a nonzero quantity of each animal.

posted 7 years ago

Oh darn, after calculating an answer for 15mins, I made a typo :mad:

Paul Clapham wrote:One is Ankit's (after correcting the typo from 30 cows to 20)

Oh darn, after calculating an answer for 15mins, I made a typo :mad:

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links

ankur rathi

Ranch Hand

Posts: 3830

posted 7 years ago

If someone says "buy me this chocolate".

You don't say "I am buying this, I am buying 0 quantity of this".

Mike Simmons wrote:ankur rathi wrote:aditee sharma wrote:How many animals ofeachcategory would you buy so that that total no. of animals is 100 ?

I think the question did say you have to buy each type of animal. Or am I interpreting it wrong!

I think you're interpreting it wrong. If someone asks "how many should I buy?" then "zero" is a perfectly acceptable answer. A negative number would (usually) be unacceptable, and a non-integer value would be unacceptable for some things (animals, cars, books, computers, for example) but perfectly acceptable for others (pounds of grain, or grams of pure gold, for example). But nothing in the question implies that you have to buy a nonzero quantity of each animal.

If someone says "buy me this chocolate".

You don't say "I am buying this, I am buying 0 quantity of this".