Радослав обнови решението на 19.03.2014 16:56 (преди над 10 години)
+def is_pangram(sentence):
+ UPPER_LETTERS = 'АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЬЮЯ'
+
+ for letter in UPPER_LETTERS:
+ if sentence.find(letter) == -1 and sentence.find(letter.lower()) == -1:
+ return False
+
+ return True
+
+def char_histogram(text):
+ histogram = dict()
+
+ for letter in text:
+ histogram[letter] = 0
+ for letter in text:
+ histogram[letter] += 1
+
+ return histogram
+
+def sort_by(func, arguments):
+ for i in range(0, len(arguments) - 1):
+ extri = i
+
+ for j in range(i + 1, len(arguments)):
+ if func(arguments[extri], arguments[j]) > 0:
+ extri = j
+
+ if not extri == i:
+ arguments[extri], arguments[j] = arguments[j], arguments[extri]
+
+ arguments.reverse()
+ return arguments
+
+def group_by_type(dictionary):
+ new_dict = dict()
+
+ for elem in dictionary:
+ new_dict[type(elem)] = dict()
+ for elem in dictionary:
+ new_dict[type(elem)][elem] = dictionary[elem]
+
+ return new_dict
+
+def anagrams(words):
+ anagrams = []
+ anagram_sets = []
+
+ for word1 in set(words).difference(anagram_sets):
+ if not word1 in anagram_sets:
+ anagrams_word = [word1,]
+ anagram_sets.append(word1)
+
+ for word2 in set(words).difference(anagram_sets):
+ sorted_word1 = list(word1)
+ sorted_word1.sort()
+ sorted_word2 = list(word2)
+ sorted_word2.sort()
+ if not word1 is word2 and sorted_word1 == sorted_word2:
+ anagrams_word.append(word2)
+ anagram_sets.append(word2)
+
+ anagrams.append(anagrams_word)
+
+ return anagrams