Йордан обнови решението на 16.03.2014 22:52 (преди над 10 години)
+import functools
+def is_pangram(sentence):
+ alphabet = [chr(i) for i in range(ord('а'), ord('я') + 1)
+ if i != ord('ы') and i != ord('э')]
+ for letter in alphabet:
+ if letter not in sentence.lower():
+ return False
+ return True
+
+def char_histogram(sentence):
+ count_each_letter = {}
+ for letter in sentence:
+ if letter not in count_each_letter:
+ count_each_letter[letter] = sentence.count(letter)
+ return count_each_letter
+
+def sort_by(funct, arguments):
+ arguments.sort(key =functools.cmp_to_key(funct))
+ return arguments
+
+def group_by_type(dictionary):
+ new_dictionary={}
+ for key in dictionary.keys():
+ if key.__class__ not in new_dictionary:
+ new_dictionary[key.__class__]={}
+ if key not in new_dictionary[key.__class__]:
+ new_dictionary[key.__class__][key] = dictionary[key]
+ return new_dictionary
+def same_strings(word1, word2):
+ for letter in word1:
+ if letter.isalpha() and letter not in word2: return False
+ return True
+
+def anagrams(word):
+ all_anagrams=[]
+ for word1 in word:
+ word_permutation = [word2 for word2 in word
+ if same_strings(word1, word2)]
+ if word_permutation not in all_anagrams:
+ all_anagrams.append(word_permutation)
+ return all_anagrams