Решение на doge от Гергана Петрова

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

Към профила на Гергана Петрова

Резултати

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

Код

def such_much(x):
if x % 15 == 0:
return 'suchmuch'
elif x % 3 == 0:
return 'such'
elif x % 5 == 0:
return 'much'
else:
return str(x)
def wow_such_much(start, end):
return [such_much(i) for i in range(start, end)]
def count_doge_words(sentence):
parasites = ['wow', 'lol', 'so', 'such', 'much', 'very']
words_in_sentence = sentence.split()
return len([word for word in words_in_sentence if word in parasites])

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

...............
----------------------------------------------------------------------
Ran 15 tests in 0.007s

OK

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

Гергана обнови решението на 06.03.2014 14:46 (преди около 10 години)

+def check(x):
+ if x % 15 == 0:
+ return 'suchmuch'
+ elif x % 3 == 0:
+ return 'such'
+ elif x % 5 == 0:
+ return 'much'
+ else:
+ return str(x)
+
+
+def wow_such_much(start, end):
+ return [check(i) for i in range(start, end)]
+
+
+def count_doge_words(sentence):
+ parasites = ['wow', 'lol', 'so', 'such', 'much', 'very']
+ words_in_sentence = sentence.split()
+ return len(set(parasites).intersection(words_in_sentence))

Гергана обнови решението на 06.03.2014 15:04 (преди около 10 години)

def check(x):
if x % 15 == 0:
return 'suchmuch'
elif x % 3 == 0:
return 'such'
elif x % 5 == 0:
return 'much'
else:
return str(x)
def wow_such_much(start, end):
return [check(i) for i in range(start, end)]
def count_doge_words(sentence):
parasites = ['wow', 'lol', 'so', 'such', 'much', 'very']
words_in_sentence = sentence.split()
- return len(set(parasites).intersection(words_in_sentence))
+ return len([word for word in words_in_sentence if word in parasites])

Гергана обнови решението на 06.03.2014 16:35 (преди около 10 години)

-def check(x):
+def such_much(x):
if x % 15 == 0:
return 'suchmuch'
elif x % 3 == 0:
return 'such'
elif x % 5 == 0:
return 'much'
else:
return str(x)
def wow_such_much(start, end):
- return [check(i) for i in range(start, end)]
+ return [such_much(i) for i in range(start, end)]
def count_doge_words(sentence):
parasites = ['wow', 'lol', 'so', 'such', 'much', 'very']
words_in_sentence = sentence.split()
return len([word for word in words_in_sentence if word in parasites])