Решение на doge от Марио Димитров

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

Към профила на Марио Димитров

Резултати

  • 10 точки от тестове
  • 0 бонус точки
  • 10 точки общо
  • 15 успешни тест(а)
  • 0 неуспешни тест(а)

Код

# Returns the required behavior for the number
def get_bahavior(number):
if number % 15 == 0:
return "suchmuch"
elif number % 3 == 0:
return "such"
elif number % 5 == 0:
return "much"
else:
return str(number)
# Applies the behavior for the range
def wow_such_much(start, end):
interval = []
interval.extend(range(start, end))
result = list(map(get_bahavior, interval))
return result
# A list of doge words is provided
def is_doge(word):
doge_words = ("wow", "lol", "so", "such", "much", "very")
return word in doge_words
# Doge words repetition is counted
def count_doge_words(sentence):
words = sentence.split()
return len(list(filter(is_doge, words)))

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

...............
----------------------------------------------------------------------
Ran 15 tests in 0.008s

OK

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

Марио обнови решението на 07.03.2014 01:04 (преди около 10 години)

+# Returns the required behavior for the number
+def get_bahavior(number):
+ if number % 15 == 0:
+ return "suchmuch"
+ elif number % 3 == 0:
+ return "such"
+ elif number % 5 == 0:
+ return "much"
+ else:
+ return str(number)
+
+
+# Applies the behavior for the range
+def wow_such_much(start, end):
+ interval = []
+ interval.extend(range(start, end))
+ result = list(map(get_bahavior, interval))
+ return result
+
+
+# A list of doge words is provided
+def is_doge(word):
+ doge_words = ("wow", "lol", "so", "such", "much", "very")
+ return word in doge_words
+
+
+# Doge words repetition is counted
+def count_doge_words(sentence):
+ words = sentence.split()
+ return len(list(filter(is_doge, words)))