Людмила обнови решението на 16.03.2014 17:10 (преди над 10 години)
+def is_pangram(sentence):
+ ALPHABET = sorted({'а', 'б', 'в', 'г', 'д', 'е', 'ж', 'з', 'и', 'й', 'к',
+ 'л', 'м', 'н', 'о', 'п', 'р', 'с', 'т', 'у', 'ф', 'х',
+ 'ц', 'ч', 'ш', 'щ', 'ъ', 'ь', 'ю', 'я'})
+ #All letters to lower-case
+ sentence = sentence.lower()
+ #Remove special characters and punctuation
+ all_letters = ''.join(e for e in sentence if e.isalnum())
+ #Take all the letters once, store them in unique_letters
+ unique_letters = "".join(set(all_letters))
+ #Order letters is alphabetical order
+ ordered_unique_letters = sorted(unique_letters)
+
+ #Return True if ordered unique letters of sentence are the alphabet
+ return ordered_unique_letters == ALPHABET
+
+#//////////////////////////////////////////////////////////////////////
+
+
+def char_histogram(text):
+
+ char_hist = {}
+ for letter in text:
+ if letter in char_hist:
+ char_hist[letter] += 1
+ else:
+ char_hist[letter] = 1
+
+ return char_hist
+
+#//////////////////////////////////////////////////////////////////////
+
+
+def group_by_type(dictionary):
+
+ grouped_dictionary = {}
+ for key in dictionary:
+ object_class = key.__class__
+ if object_class in grouped_dictionary:
+ value_dict_type = grouped_dictionary[object_class]
+ value_dict_type[key] = dictionary[key]
+ grouped_dictionary[object_class] = value_dict_type
+ else:
+ grouped_dictionary[object_class] = {key: dictionary[key]}
+
+ return grouped_dictionary
+
+#/////////////////////////////////////////////////////////////////////
+
+
+def anagrams(words):
+
+ #Contains the final result, a list of list that contains anagram words
+ result = []
+
+ #Pick the first word and find all other words that are anagrams.
+ #All anagram words are removed from the words list
+ #When there are no words left in words we're done!
+ while len(words) != 0:
+
+ #Contains words that are anagrams
+ mid_list = []
+ #Each word will be tested against test_word
+ test_word = words[0]
+ #Add test_word to the list with intermediate results(mid_list)
+ mid_list.append(test_word)
+ #First element is kept in test_word and is no longer needed
+ words.pop(0)
+
+ #Iterates through all words in list words
+ i = 0
+ while i < len(words):
+
+ #If elements are anagrams, add words[i] to mid_list and pop it
+ #Otherwise proceed with the next word
+ if is_anagram(test_word, words[i]) is True:
+ mid_list.append(words[i])
+ words.pop(i)
+ else:
+ i += 1
+
+ #Add the intermediate result to final result
+ result.append(mid_list)
+
+ return result
+
+#/////////////////////////////////////////////////////////////////////
+
+
+def is_anagram(word1, word2):
+ sorted_word1 = sorted(word1)
+ sorted_word2 = sorted(word2)
+ if sorted_word1 == sorted_word2:
+ return True
+ else:
+ return False