Problem
For two strings and of equal length, the p-distance between them, denoted , is the proportion of corresponding symbols that differ between and .
For a general distance function on taxa (taxa are often represented by genetic strings), we may encode the distances between pairs of taxa via a distance matrix in which .
Given: A collection of () DNA strings of equal length (at most 1 kbp). Strings are given in FASTA format.
Return: The matrix corresponding to the p-distance on the given strings. As always, note that your answer is allowed an absolute error of 0.001.
对于长度相等的两个字符串 ,它们之间的p距离表示为和之间不同的相应符号的比例。
对于一般的距离函数上类群(类群通常由下式表示的遗传串)中,我们可以通过编码对分类单元之间的距离的距离矩阵,其中。
给出:集合()DNA串长度相等(至多1的KBP)。字符串以FASTA格式给出。
返回值:对应于给定字符串上p距离的矩阵。与往常一样,请注意,您的答案的绝对误差为0.001。
Sample Dataset
>Rosalind_9499 TTTCCATTTA >Rosalind_0942 GATTCATTTC >Rosalind_6568 TTTCCATTTT >Rosalind_1833 GTTCCATTTA
Sample Output
0.00000 0.40000 0.10000 0.10000 0.40000 0.00000 0.40000 0.30000 0.10000 0.40000 0.00000 0.20000 0.10000 0.30000 0.20000 0.00000