Милен обнови решението на 19.03.2014 16:44 (преди над 10 години)
+def is_pangram(input_entry):
+ bul_alphabet = [chr(char) for char in range(1072, 1104)]
+ bul_alphabet.remove(chr(1099))
+ bul_alphabet.remove(chr(1101))
+ for letter in input_entry:
+ if letter.isupper() and letter.lower() in bul_alphabet:
+ bul_alphabet.remove(letter.lower())
+ if letter in bul_alphabet:
+ bul_alphabet.remove(letter)
+ if len(bul_alphabet) > 0:
+ return False
+ return True
+
+
+def char_histogram(input_entry):
+ input_list = list(input_entry)
+ dictionary = dict([(x, input_list.count(x)) for x in set(input_list)])
+ return dictionary
+
+
+def sort_by(func, arguments):
+ for x in range(0, len(arguments)):
+ for y in range(x, len(arguments)):
+ if func(arguments[x], arguments[y]) > 0:
+ arguments[x], arguments[y] = arguments[y], arguments[x]
+ return arguments
+
+
+def group_by_type(dictionary):
+ di = {}
+ list_as_tuples = dictionary.items()
+ for x in dictionary:
+ di[type(x)] = {first: second for first, second in list_as_tuples
+ if type(first) == type(x)}
+ return di
+
+
+def anagrams(words):
+ table = {}
+ for item in words:
+ word_sorted = ' '.join(sorted(item.lower()))
+ if word_sorted in table:
+ table[word_sorted].append(item)
+ else:
+ table[word_sorted] = []
+ table[word_sorted].append(item)
+
+ return [second for first, second in table.items()]