Skip to content

Instantly share code, notes, and snippets.

@cameronp98
Created January 9, 2014 21:47
Show Gist options
  • Save cameronp98/8342659 to your computer and use it in GitHub Desktop.
Save cameronp98/8342659 to your computer and use it in GitHub Desktop.
def similarity(a, b):
a, b = set(a), set(b)
return len(a.intersection(b)) / len(a.union(b))
print(similarity(["a", "b", "c"], ["a", "c"]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment