Николай обнови решението на 19.03.2014 00:50 (преди над 10 години)
+def is_pangram(sentance):
+ BG_ALPHABET = ('а', 'б', 'в', 'г', 'д', 'е', 'ж', 'з', 'и', 'й',
+ 'к', 'л', 'м', 'н', 'о', 'п', 'р', 'с', 'т', 'у',
+ 'ф', 'х', 'ц', 'ч', 'ш', 'щ', 'ъ', 'ь', 'ю', 'я')
+
+ for letter in BG_ALPHABET:
+ if letter not in sentance.lower():
+ return False
+ return True
+
+
+def char_histogram(text):
+ histogram = {}
+ for charecter in text:
+ if charecter not in histogram:
+ histogram[charecter] = 0
+ histogram[charecter] += 1
+
+ return histogram
+
+def sort_by(func, arguments):
+ sorted_arguments = arguments
+ for index1 in range(len(sorted_arguments) - 1):
+ for index2 in range(len(sorted_arguments) - 1):
+ if func(sorted_arguments[index2], sorted_arguments[index2+1]) > 0:
+ sorted_arguments[index2], sorted_arguments[index2 + 1] = \
+ sorted_arguments[index2 + 1], sorted_arguments[index2]
+
+ return sorted_arguments
+
+
+
+def group_by_type(dictionary):
+
+ result = {}
+ for key in dictionary:
+ if type(key) not in result:
+ result[type(key)] = {}
+ result[type(key)][key] = dictionary[key]
+ return result
+
+
+def is_anagram(word_1,word_2):
+ for char in ",.'-? ":
+ word_1 = word_1.replace(char, "")
+ word_2 = word_2.replace(char, "")
+
+ for letter in word_1:
+ if letter not in word_2.lower():
+ return False
+ return True
+
+
+def anagrams(words):
+
+ result = []
+ temp_result = []
+
+ for word_1 in words:
+ temp = [word_2 for word_2 in words if is_anagram(word_2,word_1)]
+ temp_result.append(temp)
+
+ for item in temp_result:
+ if item not in result:
+ result.append(item)
+
+ return result
-
index1
,index2
,word_1
иword_2
не са добри имена на променливи -
temp_result
- всички променливи са временни - кода не е напълно валиден по PEP8