Решение на doge от Емилиян Паунов

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

Към профила на Емилиян Паунов

Резултати

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

Код

def wow_such_much(start, end):
'''Returns a list of strings from a given start to a given end, in which
the numbers are divisible by 3 are replaced with the string "such", the
numbers that are divisible by 5 are replaced by the string "much", and
the numbers and divide by 3 and 5 are replaced by "suchmuch". All other
numbers are converted in their string representation.
'''
words_sequence = []
for number in range(start, end):
such_much = ''
if not number % 3:
such_much += 'such'
if not number % 5:
such_much += 'much'
if not such_much:
such_much = str(number)
words_sequence.append(such_much)
return words_sequence
def count_doge_words(sentence):
'''Returns the number of doge words in a given sentence'''
doge_words = {'wow', 'lol', 'so', 'such', 'much', 'very'}
return len([word for word in sentence.split() if word in doge_words])

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

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

OK

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

Емилиян обнови решението на 12.03.2014 12:48 (преди над 10 години)

+
+
+def wow_such_much(start, end):
+ ''' '''
+ words_sequence = []
+ for number in range(start, end):
+ such_much = ''
+ if not number % 3:
+ such_much += 'such'
+ if not number % 5:
+ such_much += 'much'
+ if not such_much:
+ such_much = str(number)
+ words_sequence.append(such_much)
+ return words_sequence
+
+
+def count_doge_words(sentence):
+ '''Returns the number of doge words in a given sentence'''
+ doge_words = {'wow', 'lol', 'so', 'such', 'much', 'very'}
+ return len([word for word in sentence.split() if word in doge_words])

Емилиян обнови решението на 12.03.2014 15:15 (преди над 10 години)

-
-
def wow_such_much(start, end):
- ''' '''
+ '''Returns a list of strings from a given start to a given end, in which
+ the numbers are divisible by 3 are replaced with the string "such", the
+ numbers that are divisible by 5 are replaced by the string "much", and
+ the numbers and divide by 3 and 5 are replaced by "suchmuch". All other
+ numbers are converted in their string representation.
+ '''
words_sequence = []
for number in range(start, end):
such_much = ''
if not number % 3:
such_much += 'such'
if not number % 5:
such_much += 'much'
if not such_much:
such_much = str(number)
words_sequence.append(such_much)
return words_sequence
def count_doge_words(sentence):
'''Returns the number of doge words in a given sentence'''
doge_words = {'wow', 'lol', 'so', 'such', 'much', 'very'}
- return len([word for word in sentence.split() if word in doge_words])
+ return len([word for word in sentence.split() if word in doge_words])