Skip to content

Instantly share code, notes, and snippets.

@usametov
Created January 9, 2018 08:31
Show Gist options
  • Save usametov/60abf28a1bdae4ee2707086e6228f495 to your computer and use it in GitHub Desktop.
Save usametov/60abf28a1bdae4ee2707086e6228f495 to your computer and use it in GitHub Desktop.
module Hamming
let distance (strand1: string) (strand2: string): int option =
if strand1.Length = strand2.Length
then
Some(Seq.zip strand1 strand2 |> Seq.sumBy (fun (a, b) -> if a = b then 0; else 1))
else None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment