Мариан обнови решението на 19.03.2014 16:41 (преди над 10 години)
+alphabet = ('а', 'б', 'в', 'г', 'д', 'е',
+ 'ж', 'з', 'и', 'й', 'к', 'л',
+ 'м', 'н', 'о', 'п', 'р', 'с',
+ 'т', 'у', 'ф', 'х', 'ц', 'ч',
+ 'ш', 'щ', 'ъ', 'ь', 'ю', 'я')
+
+def is_pangram(sentence):
+ for letter in alphabet:
+ if letter not in sentence:
+ return False
+ return True
+
+def char_histogram(text):
+ symbols_dict = {}
+ for symbol in text:
+ symbols_dict[symbol] = text.count(symbol)
+ return symbols_dict
+
+def sort_by(func, arguments):
+ for i in range(len(arguments)-1):
+ for j in range(len(arguments)-1):
+ if func(arguments[j],arguments[j+1]) > 0:
+ arguments[j],arguments[j+1] = arguments[j+1],arguments[j]
+ return arguments
+
+def group_by_type(dictionary):
+ group_dict = {}
+ keys_list = dictionary.keys()
+ for key in keys_list:
+ temp_dict = {}
+ typeof_item = type(key)
+ for id, item in dictionary.items():
+ if type(id) == typeof_item:
+ temp_dict[id] = item
+ group_dict[typeof_item] = temp_dict
+ return group_dict
+
+def anagrams(words):
+ anagrams_list = []
+ checked_words = []
+ for i in range(len(words)):
+ temp_list = []
+ character_count = char_histogram(words[i])
+ for j in range(len(words)):
+ if character_count == char_histogram(words[j]):
+ temp_list.append(words[j])
+ if character_count not in checked_words:
+ anagrams_list.append(temp_list)
+ checked_words.append(character_count)
+ return anagrams_list