Решение на doge от Илиян Влахов

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

Към профила на Илиян Влахов

Резултати

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

Код

def wow_such_much(start, end):
str_holder = []
for number in range(start, end):
str_holder.append(number)
position = str_holder.index(number)
if number % 15 ==0:
str_holder[position] = 'suchmuch'
elif number % 3 ==0:
str_holder[position] = 'such'
elif number % 5 == 0:
str_holder[position] = 'much'
else:
str_holder[position] = str(number)
return str_holder
DOGE_WORDS = ["wow", "lol", "so", "such", "much", "very"]
def count_doge_words(sentence):
count = 0
words = sentence.split()
for word in words:
if word in DOGE_WORDS:
count +=1
return count

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

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

OK

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

Илиян обнови решението на 10.03.2014 13:22 (преди над 10 години)

+def wow_such_much(start, end):
+ my_list = []
+ for number in range(start, end):
+ my_list.append(number)
+ position = my_list.index(number)
+ if number % 3 == 0 and number % 5 == 0:
+ my_list[position] = 'suchmuch'
+ elif number % 3 ==0:
+ my_list[position] = 'such'
+ elif number % 5 == 0:
+ my_list[position] = 'much'
+ else:
+ my_list[position] = str(number)
+ return my_list
+
+def count_doge_words(sentence):
+ count = 0
+ doge_words = ["wow", "lol", "so", "such", "much", "very"]
+ words = sentence.split()
+ for word in words:
+ if word in doge_words:
+ count +=1
+ return count

Илиян обнови решението на 12.03.2014 14:28 (преди над 10 години)

def wow_such_much(start, end):
- my_list = []
+ str_holder = []
for number in range(start, end):
- my_list.append(number)
- position = my_list.index(number)
- if number % 3 == 0 and number % 5 == 0:
- my_list[position] = 'suchmuch'
+ str_holder.append(number)
+ position = str_holder.index(number)
+ if number % 15 ==0:
+ str_holder[position] = 'suchmuch'
elif number % 3 ==0:
- my_list[position] = 'such'
+ str_holder[position] = 'such'
elif number % 5 == 0:
- my_list[position] = 'much'
+ str_holder[position] = 'much'
else:
- my_list[position] = str(number)
- return my_list
+ str_holder[position] = str(number)
+ return str_holder
+DOGE_WORDS = ["wow", "lol", "so", "such", "much", "very"]
+
def count_doge_words(sentence):
count = 0
- doge_words = ["wow", "lol", "so", "such", "much", "very"]
words = sentence.split()
for word in words:
- if word in doge_words:
+ if word in DOGE_WORDS:
count +=1
return count