Иван обнови решението на 15.03.2014 20:40 (преди над 10 години)
+from collections import defaultdict
+from functools import cmp_to_key
+
+
+def is_pangram(sentence):
+ alphabet = set('абвгдежзийклмнопрстуфхцчшщъьюя')
+ return alphabet.issubset(sentence.lower())
+
+def char_histogram(text):
+ result = defaultdict()
+ for symbol in text:
+ result[symbol] = text.count(symbol)
+ return dict(result)
+
+def sort_by(func, arguments):
+ return sorted(arguments, key=cmp_to_key(func))
+
+def group_by_type(dictionary):
+ result = defaultdict(dict)
+ for key in dictionary.keys():
+ result[type(key)].update({key: dictionary[key]})
+ return dict(result)
+
+def dictify(word):
+ result = defaultdict()
+ for letter in word:
+ result[letter] = word.count(letter)
+ return dict(result)
+
+def generate_group(word, words):
+ return tuple([unit for unit in words
+ if dictify(unit) == dictify(word)])
+
+def anagrams(words):
+ return [list(group) for group
+ in set([generate_group(word, words) for word in words])]