Ивайло обнови решението на 16.03.2014 18:56 (преди над 10 години)
+from functools import cmp_to_key
+
+
+def is_pangram(sentence):
+ sentence = sentence.lower()
+ count_chars = {}
+ for char in sentence:
+ if char.isalpha():
+ if char in count_chars:
+ count_chars[char] += 1
+ else:
+ count_chars[char] = 1
+
+ return len(count_chars) == 30
+
+
+def char_histogram(sentence):
+ count_chars = {}
+ for char in sentence:
+ if char in count_chars:
+ count_chars[char] += 1
+ else:
+ count_chars[char] = 1
+
+ return count_chars
+
+
+def sort_by(func, arguments):
+ return sorted(arguments, key=cmp_to_key(func))
+
+
+def group_by_type(dictionary):
+ gruped_by_type = {}
+ for key, value in dictionary.items():
+ key_type = type(key)
+ if key_type in gruped_by_type:
+ gruped_by_type[key_type].update({key: value})
+ else:
+ gruped_by_type[key_type] = {key: value}
+
+ return gruped_by_type
+
+
+def isAnagram(word1, word2):
+ word1_list = list(word1)
+ word1_list.sort()
+ word2_list = list(word2)
+ word2_list.sort()
+
+ return word1_list == word2_list
+
+
+def anagrams(words):
+ pass
-
word1_list
,word2_list
- помисли за по-добри имена -
return len(count_chars) == 30
- 30 какво е и от къде идва? Може би трябва да го изнесеш в константа.