Advertisement
Guest User

Untitled

a guest
Mar 15th, 2020
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. alphabet = "abcdefghijklmnopqrstuvwxyz"
  2. test_dups = ["zzz", "dog", "bookkeeper", "subdermatoglyphic", "subdermatoglyphics"]
  3. test_miss = ["zzz", "subdermatoglyphic", "the quick brown fox jumps over the lazy dog"]
  4.  
  5.  
  6. def histogram(s):
  7.     d = dict()
  8.     for c in s:
  9.         if c not in d:
  10.             d[c] = 1
  11.         else:
  12.             d[c] += 1
  13.     return d
  14.  
  15.  
  16. def has_duplicates(s):
  17.     h = histogram(s)
  18.     for k,v in h.items():
  19.         if v > 1:
  20.             return True
  21.     return False
  22. for s in test_dups:
  23.     if has_duplicates(s):
  24.         print(s, "has duplicates")
  25.     else:
  26.         print(s, "uses all the letters")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement