HAMM: Counting Point Mutations | Ben Cunningham

HAMM: Counting Point Mutations

Problem by Rosalind · on July 1, 2012

Given two strings and of equal length, the Hamming distance between and , denoted , is the number of corresponding symbols that differ in and . See Figure 2.

Given: Two DNA strings and of equal length (not exceeding 1 kbp).

Return: The Hamming distance .

Sample Dataset

GAGCCTACTAACGGGAT
CATCGTAATGACGGCCT

Sample Output

7

R

library(readr)
library(magrittr)

f <- "hamm.txt"
dna <-
  read_csv(f, col_names = FALSE)$X1 %>%
  strsplit(split = NULL)

sum(dna[[1]] != dna[[2]]) %>%
  cat()
7