Антонио обнови решението на 14.03.2014 01:33 (преди над 10 години)
+import functools
+
+from collections import defaultdict
+
+
+def is_pangram(sentence):
+ all_chars = {'ы', 'э'}
+
+ for char in sentence.lower():
+ if ord(char) in range(ord('а'), ord('я') + 1):
+ all_chars.add(char)
+
+ return len(all_chars) == 32
+
+
+def char_histogram(text):
+ count_char = {}
+
+ for char in text:
+ if not count_char.get(char):
+ count_char[char] = text.count(char)
+
+ return count_char
+
+
+def sort_by(func, arguments):
+ return sorted(arguments, key=functools.cmp_to_key(func))
+
+
+def group_by_type(dictionary):
+ grouped = defaultdict(lambda: {})
+
+ for key, value in dictionary.items():
+ items_till_now = list(grouped[type(key)].items())
+ grouped[type(key)] = dict(items_till_now + list({key: value}.items()))
+
+ return dict(grouped)
+
+
+def anagrams(words):
+ grouped = []
+
+ for vocable in words:
+ new = list(filter(lambda x: sorted(list(x)) == sorted(list(vocable)),
+ words))
+ if not new in grouped:
+ grouped.append(new)
+
+ return grouped
Това на 44-45 ред проблем ли е?