Беатрис обнови решението на 19.03.2014 14:33 (преди над 10 години)
+from collections import Counter, defaultdict
+from functools import cmp_to_key
+import string
+
+CYRILIC = 'абвгдежзийклмнопрстуфхцчшщъьюя'
+LATIN = string.ascii_lowercase
+ALPHABETS = CYRILIC + LATIN
+
+
+def is_pangram(sentence):
+ letters = set(CYRILIC)
+ for letter in sentence.lower():
+ if letter in letters:
+ letters.remove(letter)
+ return not letters
+
+
+def char_histogram(text):
+ return Counter(text)
+
+
+def sort_by(func, arguments):
+ return sorted(arguments, key=cmp_to_key(func))
+
+
+def group_by_type(dictionary):
+ grouped = defaultdict(dict)
+ for key, value in dictionary.items():
+ grouped[type(key)][key] = value
+ return grouped
+
+
+def anagrams(words):
+ alpha_words = (filter(lambda c: c.isalpha(), w.lower()) for w in words)
+ words_ordered = [''.join(sorted(word)) for word in alpha_words]
+ result = defaultdict(list)
+ for i in range(len(words)):
+ result[words_ordered[i]].append(words[i])
+ return list(result.values())