Данаил обнови решението на 15.03.2014 03:17 (преди над 10 години)
+__cyrillic = 'абвгдежзийклмнопрстуфхцчшщъьюя'
+
+def is_pangram(sentence):
+ return not len([1 for char in __cyrillic if char not in sentence.lower()])
+
+def char_histogram(sentence):
+ hystogram = {}
+ for symbol in sentence:
+ hystogram[symbol] = hystogram.setdefault(symbol, 0) + 1
+ return hystogram
+
+def sort_by(compare, args):
+ for arg_number in range(0, len(args) - 1):
+ for bubble in range(0, len(args) - 1 - arg_number):
+ if compare(args[bubble], args[bubble + 1]) > 0:
+ args[bubble], args[bubble + 1] = args[bubble + 1], args[bubble]
+ return args
+
+def group_by_type(dictionary):
+ type_dict = {}
+ for key in dictionary:
+ type_dict.setdefault(type(key), {})[key] = dictionary[key]
+ return type_dict
+
+def anagrams(words):
+ groups = {}
+ for word in words:
+ groups.setdefault(frozenset(char_histogram(word).items()), []).append(word)
+ return [groups[group] for group in groups]