Георги обнови решението на 16.03.2014 20:06 (преди над 10 години)
+CYRILLIC_ALPHABET = {chr(1072 + i) for i in range(32)} - {'ы', 'э'}
+
+def is_pangram(sentence):
+ return all([char in sentence.lower() for char in CYRILLIC_ALPHABET])
+
+from collections import defaultdict
+
+def char_histogram(text):
+ histogram = defaultdict(lambda: 0)
+ for char in text:
+ histogram[char] += 1
+ return histogram
+
+def sort_by(func, coll):
+ if len(coll) <= 0:
+ return []
+ pivot = coll[0]
+ smaller = list(filter(lambda x: func(pivot, x) > 0, coll))
+ equal = list(filter(lambda x: x == pivot, coll))
+ bigger = list(filter(lambda x: func(x, pivot) > 0, coll))
+ return sort_by(func, smaller) + equal + sort_by(func, bigger)
+
+def group_by_type(dictionary):
+ result = defaultdict(dict)
+ for key, value in dictionary.items():
+ result[type(key)].update({key: value})
+ return result
+
+def anagrams(words):
+ letters_sets = map(lambda word: frozenset(word.lower()), words)
+ result = defaultdict(list)
+ for letters_set, word in zip(letters_sets, words):
+ result[letters_set].append(word)
+ return list(result.values())