“I bought this guide a few days ago to prepare for my interview with Oracle. Many of the questions they asked me were from this guide. I found this book absolutely great!”
another way to solve it:
1st ant can take any direction. assuming it started moving towards ant 2.
probability tht 2nd ant will collide with 1st one = 1/2
in case 2nd ant doesnt collide with the 1st one, probability tht 3rd ant will collide with 2nd = 1/2*1/2
probability tht 3rd ant will collide with 1st one = 0
so probability tht 2 ants collide = 1/2+1/4 = 3/4
hence, probability tht there is no collision = 1-3/4 = 1/4
prob of colliding is
= a and b moving towards each other + b and c moving towards each other + c and a moving towards each other
= (1/2)* (1/2) + (1/2)* (1/2) + (1/2)* (1/2) = 3/4
Another way to look at it is in binary terms. Assume that if the ant moves in clockwise, we represent it by 1, 0 otherwise. The possible combinations are:
that makes it 2/8 cases where there will be no collision… so probability will be 1/4… generalizing it, for ‘n’ ants on ‘n’ sides, the probability will be 2/(2^n) or 1/(2^(n-1))…
Assuming the ants go in a straight line; Ants won’t collide as long as they all go the same direction.
1st and goes to a corner (doesn’t matter which).
probability that the 2nd ant goes in the same direction (1/2)
probability that the 3rd ant goes in the same direction as the first two (1/2).
Probability they are all going in the same direction (won’t collide) (1/4)
0.25
explanation:
there are 2^3 ways
only 2 ways are possible without colliding.
so 2 out of 8 ways.
Well the probability they WON’T collide is 3/4 i.e. 0.75
These things would matter I suppose.
subba is right..
another way to solve it:
1st ant can take any direction. assuming it started moving towards ant 2.
probability tht 2nd ant will collide with 1st one = 1/2
in case 2nd ant doesnt collide with the 1st one, probability tht 3rd ant will collide with 2nd = 1/2*1/2
probability tht 3rd ant will collide with 1st one = 0
so probability tht 2 ants collide = 1/2+1/4 = 3/4
hence, probability tht there is no collision = 1-3/4 = 1/4
let’s take it math:
the set of all possibilities is the set of all 3 digit binary numbers (000, …, 111) => 2^3=8
define not collide: any 2 digits are equal => 000 and 111 => 2 posibilities
so the probability is 2/8% = 25%
My explanation
suppose 3 ants named a, b, c
prob of colliding is
= a and b moving towards each other + b and c moving towards each other + c and a moving towards each other
= (1/2)* (1/2) + (1/2)* (1/2) + (1/2)* (1/2) = 3/4
therefore, prob of not colliding = 1- 3/4 = 1/4
name the ants at corners - a1, a2 and a3
a1 –> a2, a2 –> a3, a3 –> a1 ==> o.k.
a1 –> a2, a2 –> a1, a3 –> a1 ==> collide
a1 –> a2, a2 –> a1, a3 –> a2 ==> collide
similar for other cases
so the possiblities for collision = 2/3 = 66%
Another way to look at it is in binary terms. Assume that if the ant moves in clockwise, we represent it by 1, 0 otherwise. The possible combinations are:
0 0 0 - will not collide
0 0 1 - collide
0 1 0 - collide
0 1 1 - collide
1 0 0 - collide
1 0 1 - collide
1 1 0 - collide
1 1 1 - will not collide
that makes it 2/8 cases where there will be no collision… so probability will be 1/4… generalizing it, for ‘n’ ants on ‘n’ sides, the probability will be 2/(2^n) or 1/(2^(n-1))…
Ants would stop to communicate with each other unless they each headed in the same direction, i.e. clockwise or counterclockwise.
That happens 25% of the time which is what others have said.
There are 180 degrees in the triangle.
To take a degenerate case, we assume that the triangle is an equilateral triangle. So, each corner has 60 degrees.
This means, other than 60 and 0 degrees there is a possibility that they can crash. (Since random, we can assume all possibilities)
Therefore, for each angle, there are 58 degrees for which other angles that can intersect.
Hence, 180 - 6 = 174 degrees that will intersect.
Or 174/180 is the answer for which the ants can collide. Hence it’s only 6/180 or 1/30 for which the ants will not collide.
I’ve got 3 oz of grand marnier in my system. If I’m wrong, I blame it on the french!
Assuming the ants go in a straight line; Ants won’t collide as long as they all go the same direction.
1st and goes to a corner (doesn’t matter which).
probability that the 2nd ant goes in the same direction (1/2)
probability that the 3rd ant goes in the same direction as the first two (1/2).
Probability they are all going in the same direction (won’t collide) (1/4)
Leave an Answer/Comment