|We are studying sub-atomic particles. At regular time intervals, all the particles
simultaneously undergo a transformation. The state of each particle can be
represented by an integer value (which can be arbitrarily large), and each
transformation changes the state of
a particle by one of 4 values. At each transformation time, each of the particles independently
undergoes one of the 4 changes. Each of the four possibilities is equally likely to occur to each particle.
We believe that whenever two adjacent particles transform to have identical states,
they annihilate each other.
We will call a pair of particles "unstable" if there is a
sequence of transformations that could lead to an annihilation.
We need to estimate the probability that two adjacent particles are unstable.
To make this specific, we will choose two
particles and assume that each is equally likely to have any initial state between
-4999 and 5000 inclusive (a state of 0 is possible). Create a class AntiMatter
that contains a method unstable that receives a int xform containing the
4 legal transformation amounts and returns the probability that there
exists a sequence of transformations for the two particles that would lead to mutual
The method should return the probability as a String with a decimal point,
exactly eight digits to the right of the decimal point, and no leading zeros.
Since there are 100,000,000 equally likely pairs, this probability will be exact.