Стефан обнови решението на 19.03.2014 16:30 (преди над 10 години)
+from collections import defaultdict
+
+
+def is_pangram(sentence):
+ letters = dict()
+ sentence_to_lower = sentence.lower()
+ for letter in range(1072, 1104):
+ letters[chr(letter)] = False
+ del letters[chr(1099)]
+ del letters[chr(1101)]
+
+ for letter in sentence_to_lower:
+ if ord(letter) >= 1072 and ord(letter) <= 1103 and not letters[letter]:
+ letters[letter] = True
+
+ for value in letters.values():
+ if not value:
+ return False
+
+ return True
+
+
+def char_histogram(text):
+ return {letter: text.count(letter) for letter in text}
+
+
+def sort_by(func, arguments):
+ for index in range(0, len(arguments)):
+ for other_index in range(index, len(arguments)):
+ if func(arguments[index], arguments[other_index]) > 0:
+ temp = arguments[index]
+ arguments[index] = arguments[other_index]
+ arguments[other_index] = temp
+
+ return arguments
+
+
+def group_by_type(dictionary):
+ sorted_by_type = defaultdict(dict)
+ for key, value in dictionary.items():
+ sorted_by_type[type(key)].update({key: value})
+
+ return sorted_by_type
+
+
+def anagrams(words):
+ sorted_words = defaultdict(list)
+ for word in words:
+ sorted_words[' '.join(sorted(word.lower()))].append(word)
+
+ return [value for key, value in sorted_words.items()]