Jaadu mailed me this problem today. I was able to solve it and I am happy. This is an "intelligent" problem. Solution so elegant that you will fall in love with it. :)
Assume 100 ants are moving in 1 dimensional plane, all move with the same speed. Some are moving towards the positive x axis and some towards negative. If a collision occurs between two ants both ants changes the direction. If you are given direction of motion of each ant, what is the number of collision that will occur? Give an algorithm. :)
Update (11/12/09): Solution by A Rustle (Prathmesh, CSE, IITB) in comments !!
Quant, Math & Computer Science Puzzles for Interview Preparation & Brain Teasing
A collection of ~225 Puzzles with Solutions (classified by difficulty and topic)
Subscribe to:
Post Comments (Atom)
Fraction Brainteaser
Source: Sent to me by Gaurav Sinha Problem: Siddhant writes a Maths test and correctly answers 5 out of 6 Arithmetic questions and 20...

This is not a puzzle. So, for those of you who follow this puzzle blog, please bear with me for just one post. Interesting Math in this art...

Let's say A keep tossing a fair coin, until he get 2 consecutive heads, define X to be the number of tosses for this process; B keep tos...

Source: Sent to me by Gaurav Sinha Problem: Siddhant writes a Maths test and correctly answers 5 out of 6 Arithmetic questions and 20...
For an ant moving right, count the number of ants to its right moving left. Add this number for every right moving ant. That is the number of collisions.
ReplyDeletehint: on every collision, assume that the two ants don't change direction but simply cross each other.
@Rustle
ReplyDeleteGreat!! Correct!! Nice solution..
nice solution good question
ReplyDeleteIts a nice problem. i was thinking of writing about...(trying to cp u)
ReplyDelete:)
ReplyDeleteyo dharme!!