Гено обнови решението на 19.03.2014 10:16 (преди над 10 години)
+from collections import Counter
+
+def is_pangram(sentence):
+ all_letters = 'абвгдежзийклмнопрстуфхцчшщъьюя'
+ for letter in all_letters:
+ if letter.lower() not in sentence.lower():
+ return False
+ return True
+
+def char_histogram(text):
+ histogram = Counter()
+ for char in text:
+ histogram[char] += 1
+ return histogram
+
+def sort_by(func, arguments):
+ b_unsorted = True
+ while b_unsorted:
+ b_unsorted = False
+ for i in range(0,len(arguments)-1):
+ if func(arguments[i], arguments[i+1]) >= 0:
+ tmp = arguments[i+1]
+ arguments[i+1] = arguments[i]
+ arguments[i] = tmp
+ b_unsorted = True
+ if not b_unsorted:
+ return arguments
+
+def anagrams(words):
+ output = []
+ histograms = map(char_histogram, words)
+ already_found_histograms = []
+ histogram_words = []
+ for word_index_1 in range(0,len(words)):
+ if words[word_index_1] in already_found_histograms:
+ continue
+ histogram_words = [(words[word_index_1])]
+ already_found_histograms.append(words[word_index_1])
+ for word_index_2 in range(0,len(words)):
+ if words[word_index_2] in already_found_histograms:
+ continue
+ if histograms[word_index_1] == histograms[word_index_2]:
+ histogram_words.append(words[word_index_2])
+ already_found_histograms.append(words[word_index_2])
+ output.append(histogram_words)
+ return output
+
+def group_by_type(dictionary):
+ output = {}
+ for key in dictionary:
+ if type(key) not in output:
+ output[type(key)] = {}
+ output[type(key)][key] = dictionary[key]
+ return output