Константин обнови решението на 14.03.2014 15:28 (преди над 10 години)
+from collections import defaultdict
+
+
+def is_pangram(sentence):
+ alfabeth = set(list("ахчуднабългарсказемьополюшвайцъфтящижита"))
+ counter = 0
+
+ for letter in alfabeth:
+ if letter in sentence:
+ counter += 1
+
+ return counter == 30
+
+
+def char_histogram(text):
+ letters = list(text)
+ histogram = dict()
+
+ for letter in letters:
+ if letter in histogram:
+ histogram[letter] += 1
+ else:
+ histogram[letter] = 1
+
+ return histogram
+
+
+def sort_by(func, arguments):
+ swapped = True
+ while swapped == True:
+ swapped = False
+ for i in range(1, len(arguments)):
+ if func(arguments[i - 1], arguments[i]) > 0:
+ arguments[i - 1], arguments[i] = arguments[i], arguments[i - 1]
+ swapped = True
+
+ return arguments
+
+
+def group_by_type(dictionary):
+ type_dict = defaultdict(dict)
+
+ for key in dictionary:
+ k_type = type(key)
+ if k_type not in type_dict:
+ type_dict[k_type] = {k: dictionary[k] for k in dictionary
+ if type(k) == k_type}
+
+ return type_dict
+
+
+def anagrams(words):
+ anagram_classes = list()
+ for word in words:
+ word_anagrams = [x for x in words if sorted(word) == sorted(x)]
+ if word_anagrams not in anagram_classes:
+ anagram_classes.append(word_anagrams)
+
+ return anagram_classes