Решение на Пет функции от Антон Стоянов

Обратно към всички решения

Към профила на Антон Стоянов

Резултати

  • 7 точки от тестове
  • 0 бонус точки
  • 7 точки общо
  • 11 успешни тест(а)
  • 5 неуспешни тест(а)

Код

#!/usr/bin/python
#-*- coding: cp1251 -*-
from _functools import cmp_to_key
def is_pangram(sentence):
input_set = set(sentence.lower())
the_bulgarian_alphabet = set('абвгдежзийклмнопрстуфхцчшщъьюя')
intersected_set = input_set.intersection(the_bulgarian_alphabet)
return len(intersected_set) is len(the_bulgarian_alphabet)
def char_histogram(text):
histogram_dict = {x : 0 for x in set(text)}
for x in list(text):
histogram_dict[x] = histogram_dict[x]+1
return histogram_dict
def sort_by(func, arguments):
arguments.sort(key=cmp_to_key(func))
return arguments
def group_by_type(dictionary):
typed_dict = {}
for x in dictionary.keys():
if type(x) in typed_dict.keys():
typed_dict[type(x)].update({x:dictionary[x]})
else:
typed_dict[type(x)] = {x:dictionary[x]}
return typed_dict
def anagrams(words):
return words

Лог от изпълнението

▸ Покажи лога

История (1 версия и 1 коментар)

Антон обнови решението на 19.03.2014 16:46 (преди около 11 години)

▸ Покажи разликите
+#!/usr/bin/python
+#-*- coding: cp1251 -*-
+
+from _functools import cmp_to_key
+
+def is_pangram(sentence):
+ input_set = set(sentence.lower())
+ the_bulgarian_alphabet = set('абвгдежзийклмнопрстуфхцчшщъьюя')
+ intersected_set = input_set.intersection(the_bulgarian_alphabet)
+ return len(intersected_set) is len(the_bulgarian_alphabet)
+
+def char_histogram(text):
+ histogram_dict = {x : 0 for x in set(text)}
+ for x in list(text):
+ histogram_dict[x] = histogram_dict[x]+1
+ return histogram_dict
+
+
+def sort_by(func, arguments):
+ arguments.sort(key=cmp_to_key(func))
+ return arguments
+
+def group_by_type(dictionary):
+ typed_dict = {}
+ for x in dictionary.keys():
+ if type(x) in typed_dict.keys():
+ typed_dict[type(x)].update({x:dictionary[x]})
+ else:
+ typed_dict[type(x)] = {x:dictionary[x]}
+ return typed_dict
+
+def anagrams(words):
+ return words