Гергана обнови решението на 19.03.2014 15:45 (преди над 10 години)
+import functools
+from collections import Counter
+
+
+def is_pangram(sentence):
+ cyrillic = {'я', 'ю', 'ь', 'ъ', 'щ', 'ш', 'ч', 'ц', 'х', 'ф', 'у', 'т',
+ 'с', 'р', 'м', 'п', 'о', 'н', 'л', 'к', 'й', 'и', 'з', 'ж',
+ 'е', 'д', 'г', 'в', 'б', 'а'}
+ alphabet = {character for character in set(sentence.lower())
+ if character in cyrillic}
+ if len(alphabet) == 30:
+ return True
+ return False
+
+
+def char_histogram(text):
+ symbol_count = Counter(list(text))
+ return symbol_count
+
+
+def sort_by(func, arguments):
+ result = sorted(arguments, key=functools.cmp_to_key(func))
+ return(result)
+
+
+def group_by_type(dictionary):
+ new_dictionary = {type(new_key_type):
+ {old_key: old_value for old_key, old_value in
+ dictionary.items() if type(old_key) == type(new_key_type)
+ } for new_key_type in dictionary.keys()}
+ return(new_dictionary)
+
+
+def to_characters(word):
+ new_word = "".join(filter(lambda c: c.isalpha(), word))
+ return new_word
+
+
+def anagrams(words):
+ unique_words = []
+ for each in words:
+ if sorted(to_characters(each).lower()) not in unique_words:
+ unique_words.append(sorted(to_characters(each)))
+ grouped_words = [[member for member in words
+ if unique == sorted(to_characters(member).lower())]
+ for unique in unique_words]
+ return(grouped_words)