File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Puzzle Time!

 
aditee sharma
Ranch Hand
Posts: 182
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)...
 
Ryan McGuire
Ranch Hand
Posts: 1048
4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20183
25
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3830
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3028
10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3830
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 453
Google Web Toolkit Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
94 goats ----> 47 rs
5 horses ----> 50 rs
1 cow -----> 3 rs
100 100



avi sinha
 
Mike Simmons
Ranch Hand
Posts: 3028
10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic