Милица обнови решението на 16.03.2014 00:02 (преди над 10 години)
+def is_pangram(sentence):
+ sentence_letters = list(set(sentence.lower()))
+ cyrilic_alphabeth = "абвгдежзийклмнопрстуфхцчшщъьюя"
+ return len([x for x in sentence_letters if x.isalpha()
+ and x in cyrilic_alphabeth]) == 30
+
+
+def char_histogram(sentence):
+ return {letter: list(sentence).count(letter) for letter in list(sentence)}
+
+
+def sort_by(sorting_function, sort_this):
+ for i in range(1, len(sort_this)):
+ j = i
+ while sorting_function(sort_this[j - 1], sort_this[j]) > 0 and j > 0:
+ sort_this[j - 1], sort_this[j] = sort_this[j], sort_this[j - 1]
+ j -= 1
+ return sort_this
+
+
+def group_by_type(dictionary):
+ new_dictionary = {}
+ for item in dictionary:
+ if type(item) in new_dictionary.keys():
+ new_dictionary[type(item)][item] = dictionary[item]
+ else:
+ new_dictionary[type(item)] = {}
+ new_dictionary[type(item)][item] = dictionary[item]
+ return new_dictionary
+
+
+def is_anagrams(first_word, second_word):
+ first_word = [letter for letter in first_word if letter.isalpha()]
+ second_word = [letter for letter in second_word if letter.isalpha()]
+ first_word.sort()
+ second_word.sort()
+ return first_word == second_word
+
+
+def anagrams(words):
+ list_anagrams = []
+ for word in words:
+ anagrams_of_current_word = [anagram for anagram in words
+ if is_anagrams(list(word.upper()),
+ list(anagram.upper()))]
+ if anagrams_of_current_word not in list_anagrams:
+ list_anagrams.append(anagrams_of_current_word)
+ return list_anagrams
Супер, единствено имената sort_this
и new_dictionary
не ми харесват