-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiev.py
35 lines (31 loc) · 968 Bytes
/
iev.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/env python3
import sys
import numpy
"""
Given: The six given positive integers represent the number of couples having
the following genotypes:
1. AA-AA
2. AA-Aa
3. AA-aa
4. Aa-Aa
5. Aa-aa
6. aa-aa
Return: The expected number of offspring displaying the dominant phenotype in
the next generation, under the assumption that every couple has
exactly two offspring.
Punnett Squares:
A A A a a a
A AA AA AA Aa Aa Aa
A AA AA AA Aa Aa Aa
1 1 1
A AA AA AA Aa Aa Aa
a Aa Aa Aa aa aa aa
1 3/4 1/2
a Aa Aa Aa aa aa aa
a Aa Aa Aa aa aa aa
1 1/2 0
"""
# f(a b c d e f) = 2a + 2b + 2c + 3d/2 + e + 0*f
couples_per_genotype = numpy.loadtxt(sys.stdin)
num_offspring = 2 * numpy.sum(couples_per_genotype * [1, 1, 1, 0.75, 0.5, 0])
print(num_offspring)