Решение на doge от Теодор Драганов

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

Към профила на Теодор Драганов

Резултати

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

Код

def wow_such_much(start , end):
lst = []
for current in range(start , end):
item_to_add = ''
if current % 3 == 0:
item_to_add += 'such'
if current % 5 == 0:
item_to_add += 'much'
if len(item_to_add)==0 :
lst.append(str(current))
else :
lst.append(item_to_add)
return lst
def count_doge_words(sentence):
sentence = sentence.split()
doge_words_occurrences = 0
doge_words = ['wow' , 'lol' , 'so' , 'such' , 'much' , 'very']
for split_word in sentence:
for doge_word in doge_words:
if doge_word == split_word :
doge_words_occurrences += 1
return doge_words_occurrences

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

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

OK

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

Теодор обнови решението на 06.03.2014 04:52 (преди над 10 години)

+def wow_such_much(start , end):
+ lst = []
+ for current in range(start , end):
+ item_to_add = ''
+ if current % 3 == 0:
+ item_to_add += 'such'
+ if current % 5 == 0:
+ item_to_add += 'much'
+ if len(item_to_add)==0 :
+ lst.append(str(current))
+ else :
+ lst.append(item_to_add)
+ return lst
+
+def count_doge_words(sentence):
+ doge_words_occurrences = 0
+ doge_words = ['wow' , 'lol' , 'so' , 'such' , 'much' , 'very']
+ for start in range(len(sentence)):
+ for word in doge_words:
+ if word == sentence[start:start+len(word)] :
+ doge_words_occurrences += 1
+ return doge_words_occurrences

Теодор обнови решението на 06.03.2014 16:01 (преди над 10 години)

def wow_such_much(start , end):
lst = []
for current in range(start , end):
item_to_add = ''
if current % 3 == 0:
item_to_add += 'such'
if current % 5 == 0:
item_to_add += 'much'
if len(item_to_add)==0 :
lst.append(str(current))
else :
lst.append(item_to_add)
return lst
def count_doge_words(sentence):
+ sentence = sentence.split()
doge_words_occurrences = 0
doge_words = ['wow' , 'lol' , 'so' , 'such' , 'much' , 'very']
- for start in range(len(sentence)):
- for word in doge_words:
- if word == sentence[start:start+len(word)] :
+ for split_word in sentence:
+ for doge_word in doge_words:
+ if doge_word == split_word :
doge_words_occurrences += 1
return doge_words_occurrences