Петър обнови решението на 19.03.2014 00:43 (преди над 10 години)
+from functools import cmp_to_key
+
+
+def is_pangram(sentence):
+ bulgarian_alphabet = "абвгдежзийклмнопрстуфхцчшщъьюя"
+ return set(bulgarian_alphabet) <= set(sentence.lower())
+
+
+def char_histogram(text):
+ histogram = {}
+ for unique_symbol in set(text):
+ histogram[unique_symbol] = text.count(unique_symbol)
+ return histogram
+
+
+def sort_by(func, arguments):
+ return sorted(arguments, key=cmp_to_key(func))
+
+
+def group_by_type(dictionary):
+ group_types = {}
+ for key, value in dictionary.items():
+ group_types.setdefault(type(key), {key: value})
+ group_types[type(key)][key] = value
+ return group_types
+
+
+def anagrams(words):
+ group_anagrams = {}
+ for word in words:
+ sorted_letters = "".join(x.lower() for x in sorted(word)
+ if x.isalpha())
+ group_anagrams.setdefault(sorted_letters, [word])
+ group_anagrams[sorted_letters].append(word)
+ anagrams = []
+ for (x, y) in group_anagrams.items():
+ anagrams.append(y)
+ return anagrams