Skip to content

Instantly share code, notes, and snippets.

@amonshiz
Created February 15, 2015 14:37
Show Gist options
  • Save amonshiz/5b1090712f9c6e8032d1 to your computer and use it in GitHub Desktop.
Save amonshiz/5b1090712f9c6e8032d1 to your computer and use it in GitHub Desktop.
import qualified Bioinformatics.DNANucleotide as D
hammingDistance :: (Eq a) => [a] -> [a] -> Int
hammingDistance l1 l2 = sum . map (\(f,s) -> if f == s then 0 else 1) $ zip l1 l2
main = do
string1 <- getLine
string2 <- getLine
let dnaString1 = map D.charToDNANucleotide string1
let dnaString2 = map D.charToDNANucleotide string2
putStrLn . show $ hammingDistance dnaString1 dnaString2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment