Advertisement
treyhunner

anagram?

May 5th, 2016
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.23 KB | None | 0 0
  1. from collections import Counter
  2.  
  3. def detect_anagrams(word, candidates):
  4.     return [c for c in candidates if is_anagram(word, c)]
  5.  
  6. def is_anagram(a, b):
  7.     a, b = a.upper(), b.upper()
  8.     return Counter(a) == Counter(b) and a != b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement