Драгомир обнови решението на 14.03.2014 05:30 (преди около 11 години)
▸ Покажи разликите+def is_pangram(sentence):
+ return all(character in list(sentence.lower()) for character in [
+ 'а', 'б', 'в', 'г', 'д', 'е',
+ 'ж', 'з', 'и', 'й', 'к', 'л',
+ 'м', 'н', 'о', 'п', 'р', 'с',
+ 'т', 'у', 'ф', 'х', 'ц', 'ч',
+ 'ш', 'щ', 'ъ', 'ь', 'ю', 'я'
+ ])
+
+
+def anagrams_helper(other_word, words):
+ result = []
+ for word in words:
+ if all(character in other_word for character in list(word)):
+ result.append(word)
+ return result
+
+
+def anagrams(words):
+ result = []
+ for word in words:
+ if anagrams_helper(word, words) not in result:
+ result.append(anagrams_helper(word, words))
+ return result
+
+
+def char_histogram(text):
+ result = {}
+ letters = []
+ for character in list(text):
+ if character not in letters:
+ letters.append(character)
+ result[character] = list(text).count(character)
+ return result
+
+
+def group_by_type_helper(key_type, dictionary):
+ result = {}
+ for key in dictionary:
+ if key_type is type(key):
+ result[key] = dictionary[key]
+ return result
+
+
+def group_by_type(dictionary):
+ result = {}
+ key_types = []
+ for key in dictionary:
+ if type(key) not in key_types:
+ key_types.append(type(key))
+ result[type(key)] = group_by_type_helper(type(key), dictionary)
+ return result
+
+
+def check_if_sorted(func, arguments):
+ for position in range(len(arguments) - 1):
+ if func(arguments[position], arguments[position + 1]) > 0:
+ return False
+ return True
+
+
+def sort_by(func, arguments):
+ while not check_if_sorted(func, arguments):
+ for position in range(len(arguments) - 1):
+ if func(arguments[position], arguments[position + 1]) > 0:
+ arguments[position], arguments[position + 1] = \
+ arguments[position + 1], arguments[position]
+ return arguments