3 N ANTS
There are only two possibilities in which collision can be occurred.
- All ants move in counterclockwise direction.
- All ants move in anti-counterclockwise direction.
Since every ant has two choices (pick either of two edges going through the corner on which ant is initially sitting). So for N ants there are total 2N
possibilities.
Probability that none of the ants collide = ( 2N
- 2)/ 2N
= ( 2N-1
- 1)/ 2N-1
import math
# Non Collide Probability for N ANTS
# N Number of Ants & N > 2
N = 3
# P Probability
P = (math.pow(2,N-1)-1)/math.pow(2,N-1)
print('Probability that none of', N, 'ants collide:', P)
Output:
Probability that none of 3 ants collide: 0.75
If you set N = 4 then output:
Probability that none of 4 ants collide: 0.875
If you set N = 10 then output:
Probability that none of 10 ants collide: 0.998046875