Атанас обнови решението на 17.03.2014 14:41 (преди над 10 години)
+def is_pangram(input_sentence):
+ bg_alphabet = set(['а', 'б', 'в', 'г', 'д', 'е', 'ж', 'з',
+ 'и', 'й', 'к', 'л', 'м', 'н', 'о', 'п',
+ 'р', 'с', 'т', 'у', 'ф', 'х', 'ц', 'ч',
+ 'ш', 'щ', 'ъ', 'ь', 'ю', 'я'])
+ set_of_setnece_chars = set()
+
+ for ch in input_sentence:
+ set_of_setnece_chars.add(ch)
+
+ return len(bg_alphabet-set_of_setnece_chars) == 0
+
+
+def char_histogram(input_text):
+ symbols_number = defaultdict(int)
+ for symbol in list(input_text):
+ symbols_number[symbol] = symbols_number[symbol] + 1
+
+ return dict(symbols_number)
+
+
+def sort_by(func, arguments):
+ return sorted(arguments, key=cmp_to_key(func))
+
+
+def group_by_type(input_dict):
+
+ grouped_by_type = dict()
+ for key, value in input_dict.items():
+ if type(key) in grouped_by_type.keys():
+ grouped_by_type[type(key)][key] = value
+ else:
+ new_entry = {key: value}
+ grouped_by_type[type(key)] = new_entry
+
+ return grouped_by_type
+
+
+def anagrams(input_words):
+ anagrams_to_return = []
+
+ for word in input_words:
+ possible_anagrams = list(map("".join, itertools.permutations(word)))
+
+ anagrams_for_word = []
+ for anagram in possible_anagrams:
+ if anagram in input_words:
+ # remove the entry in the orig list
+ input_words = list(filter(lambda a: a != anagram, input_words))
+ anagrams_for_word.append(anagram)
+
+ anagrams_to_return.append(anagrams_for_word)
+
+ return list(filter(lambda a: len(a) > 0, anagrams_to_return))