Дарина обнови решението на 16.03.2014 16:46 (преди над 10 години)
+CYRILLIC_ALPHABET = ('а', 'б', 'в', 'г', 'д', 'е', 'ж', 'з', 'и', 'й', 'к',
+ 'л', 'м', 'н', 'о', 'п', 'р', 'с', 'т', 'у', 'ф', 'х', 'ц', 'ч', 'ш', 'щ',
+ 'ъ', 'ь', 'ю', 'я')
+
+def is_pangram(sentence):
+ sentence.lower()
+ for letter_index in range(30):
+ if CYRILLIC_ALPHABET[letter_index] not in sentence:
+ return False
+ else:
+ return True
+
+def char_histogram(text):
+ histogram = dict()
+ for symbol in text:
+ if symbol in histogram.keys():
+ histogram[symbol] += 1
+ else:
+ histogram[symbol] = 1
+ return histogram
+
+def sort_by(func, arguments):
+ for index in range(len(arguments) - 1):
+ for second_index in range(index + 1, len(arguments)):
+ if func(arguments[index], arguments[second_index]) > 0:
+ dummy_element = arguments[index]
+ arguments[index] = arguments[second_index]
+ arguments[second_index] = dummy_element
+ return arguments
+
+def group_by_type(dictionary):
+ grouped_by_type = {}
+ for key in dictionary.keys():
+ if type(key) not in grouped_by_type.keys():
+ grouped_by_type[type(key)] = {}
+ grouped_by_type[type(key)][key] = dictionary[key]
+ else:
+ grouped_by_type[type(key)][key] = dictionary[key]
+ return grouped_by_type
+
+def are_anagrams(first_word, second_word):
+ if len(first_word) != len(second_word) or first_word == second_word:
+ return False
+ else:
+ for symbol in first_word:
+ if symbol not in second_word:
+ return False
+ return True
+
+def anagrams(words):
+ grouped_anagrams = []
+ for word in words:
+ anagram_found = False
+ if len(grouped_anagrams) == 0:
+ grouped_anagrams.append([word])
+ anagram_found = True
+ for group in grouped_anagrams:
+ if are_anagrams(group[0], word):
+ group.append(word)
+ anagram_found = True
+ break
+ if not anagram_found:
+ grouped_anagrams.append([word])
+ return grouped_anagrams