ECOO '13 R3 P2 - Mutant Children

View as PDF

Submit solution


Points: 10 (partial)
Time limit: 1.0s
Memory limit: 64M

Problem type

The field of Genetic Algorithms was inspired by what we know about evolutionary theory and the chemistry of sexual reproduction. Computer scientists use genetic algorithms when they have a problem they don't know how to solve, but can represent a possible solution as a "chromosome" – that is, a string of binary "genes".

Here's an example chromosome with 25 genes:

1101101100011010100011111

The Genetic Algorithm starts with a population of randomly generated chromosomes like the one above, all the same length, then selects the best ones to "breed" to produce "children" and repeats the process until an acceptable solution is found. The hope is that after hundreds or thousands of generations, you will find at least one good solution to your problem.

When two "parents" produce children, it goes like this:

  1. Pair up the parents
    1101101100011010100011111 ← first parent
    0010110001111000101001100 ← second parent
  2. Pick two crossover points (A and B)
    1101101100011010100011111
    0010110001111000101001100
         A              B
    Note: A and B must be different and can't be the first or last gene location.
  3. Exchange genes to produce two children. To do this, the parents swap their middle sections using the crossover points from step 2.
    1101110001111000101001111 ← first child
    0010101100011010100011100 ← second child
  4. Mutate the children by randomly changing a few genes.
    0101110001100000101001111
    0011101100011010101011000

Every Genetic Algorithm has a "mutation rate" parameter that represents the probability that each gene will mutate when children are produced. For example if the mutation rate is 0.05 then every gene in every child produced has a 5\% chance of mutation.

Your job in this question is to estimate the mutation rate given a pair of parents and one of their two children. To make your estimate, find the minimum possible number of mutations in the child assuming that it was produced through the process described above, then divide this minimum number of mutations by the number of genes to get the estimated mutation rate.

The input contains 10 test cases. Each test case consists of 3 chromosomes of equal length, each on a separate line. Chromosome length can range from 10 to 10\,000 genes. The first two chromosomes in each test case are the parents and the third is one of the two children produced from these parents. Your job is to output a floating point number rounded to two decimal places that represents your estimate of the mutation rate. You must include a leading 0 in your answer and you must output two decimal places. For example, if the estimated mutation rate is 30\% you should output 0.30.

Sample Input

0001000010
0100100011
1000101010
01101010011
00000100101
01010100011
101001100110
100011001101
110011000010
1011111101110
1000110000100
1110110000110
11001001110010
01000111011010
01111011100110
110011111011010
100101111110001
110101111010110
1001111010111100
1111111100000101
1000101100001111
11011011100000110
00010001100010100
11011001001010110
100010110010100000
110010101111110000
100010101111101100
0010100110111100101
1000011111101010011
1001100000010111100

Sample Output

0.20
0.09
0.17
0.08
0.36
0.13
0.25
0.12
0.11
0.42

Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org


Comments

There are no comments at the moment.