Editorial for MWC '15 #1 P4: Genetic Probability
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
The
Let's solve
- Parent 1's first allele + Parent 2's first allele
- Parent 1's first allele + Parent 2's second allele
- Parent 1's second allele + Parent 2's first allele
- Parent 1's second allele + Parent 2's second allele
For example, if the parents' traits are Aa
and Aa
, then the offspring's trait will be:
AA
with probability .Aa
with probability . Remember thataA
is the same asAa
.aa
with probability .
Your code must handle all combinations of traits. Each of the AA
, Aa
, or aa
. Also, the probability must be one of
Time complexity:
Comments