aspose file tools*
The moose likes Meaningless Drivel and the fly likes Puzzle Time! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Other » Meaningless Drivel
Bookmark "Puzzle Time!" Watch "Puzzle Time!" New topic
Author

Puzzle Time!

aditee sharma
Ranch Hand

Joined: Jul 22, 2008
Posts: 182
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 ?
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9313
    
  17

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)...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ryan McGuire
Ranch Hand

Joined: Feb 18, 2005
Posts: 1012
    
    3
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.

Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2861
    
  11

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.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18882
    
    8

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.
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
aditee sharma wrote:How many animals of each category 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!
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3018
    
  10
ankur rathi wrote:
aditee sharma wrote:How many animals of each category 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.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9313
    
  17

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:
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Mike Simmons wrote:
ankur rathi wrote:
aditee sharma wrote:How many animals of each category 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".


avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 453

94 goats ----> 47 rs
5 horses ----> 50 rs
1 cow -----> 3 rs
100 100



avi sinha


SCJP 5.0 SCWCD 5.0
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3018
    
  10
ankur rathi wrote:If someone says "buy me this chocolate".
You don't say "I am buying this, I am buying 0 quantity of this".


True, but that isn't what the original question said.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Puzzle Time!