Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alphabet = "abcdefghijklmnopqrstuvwxyz"
- test_dups = ["zzz", "dog", "bookkeeper", "subdermatoglyphic", "subdermatoglyphics"]
- test_miss = ["zzz", "subdermatoglyphic", "the quick brown fox jumps over the lazy dog"]
- def histogram(s):
- d = dict()
- for c in s:
- if c not in d:
- d[c] = 1
- else:
- d[c] += 1
- return d
- def has_duplicates(s):
- h = histogram(s)
- for k,v in h.items():
- if v > 1:
- return True
- return False
- for s in test_dups:
- if has_duplicates(s):
- print(s, "has duplicates")
- else:
- print(s, "uses all the letters")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement