Снежана обнови решението на 15.03.2014 10:31 (преди над 10 години)
+import collections
+from collections import defaultdict
+ALPHABET = 'абвгдежзийклмнопрстуфхцчшщьюяъ'
+
+def is_pangram(string):
+ return len(set([x for x in list(string.lower()) if x in ALPHABET])) == 30
+
+def char_histogram(string):
+ return dict(collections.Counter(list(string)))
+
+def sort_by(func, arguments):
+ for i in range(len(arguments)-1):
+ for i in range(len(arguments)-1):
+ if func(arguments[i], arguments[i+1]) > 0:
+ arguments[i], arguments[i+1] = arguments[i+1], arguments[i]
+ return arguments
+
+def group_by_type(dictionary):
+ grouped_items = collections.defaultdict(lambda: dict())
+ for key, value in dictionary.items():
+ grouped_items[type(key)][key] = value
+ return dict(grouped_items)
+
+def anagrams(words):
+ anagrams = defaultdict(list)
+ for word in words:
+ anagrams[tuple(sorted(word))].append(word)
+ return list(anagrams.values())