Решение на doge от Александър Златков

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

Към профила на Александър Златков

Резултати

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

Код

def wow_such_much(start, end):
result = []
for i in range(start, end):
if i % 15 == 0:
result.append('suchmuch')
elif i % 3 == 0:
result.append('such')
elif i % 5 == 0:
result.append('much')
else:
result.append(str(i))
return result;
def count_doge_words(sentence):
bad_words = {'wow', 'lol', 'so', 'such', 'much'}
words = sentence.split()
bad_words_count = 0
for word in words:
if word in bad_words:
bad_words_count += 1
return bad_words_count

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

....FF.........
======================================================================
FAIL: test_with_more_space_between_parasites (test.TestDogeSay)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20141216-14586-19kvx9x/test.py", line 67, in test_with_more_space_between_parasites
    self.assertEqual(6, solution.count_doge_words('wow  lol    so  such   much      very'))
AssertionError: 6 != 5

======================================================================
FAIL: test_with_parasite_sentence (test.TestDogeSay)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20141216-14586-19kvx9x/test.py", line 58, in test_with_parasite_sentence
    self.assertEqual(6, solution.count_doge_words('wow lol so such much very'))
AssertionError: 6 != 5

----------------------------------------------------------------------
Ran 15 tests in 0.011s

FAILED (failures=2)

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

Александър обнови решението на 06.03.2014 01:26 (преди над 10 години)

+def wow_such_much(start, end):
+ result = []
+ for i in range(start, end):
+ if i % 3 == 0 and i % 5 == 0:
+ result.append('suchmuch')
+ elif i % 3 == 0:
+ result.append('such')
+ elif i % 5 == 0:
+ result.append('suchmuch')
+ else:
+ result.append(str(i))
+
+ return result;
+
+
+def count_doge_words(sentence):
+ bad_words = {'wow', 'lol', 'so', 'such', 'much'}
+ words = sentence.split()
+ bad_words_count = 0
+ for word in words:
+ if word in bad_words:
+ bad_words_count += 1
+
+ return bad_words_count

Александър обнови решението на 06.03.2014 01:33 (преди над 10 години)

def wow_such_much(start, end):
result = []
for i in range(start, end):
if i % 3 == 0 and i % 5 == 0:
result.append('suchmuch')
elif i % 3 == 0:
result.append('such')
elif i % 5 == 0:
- result.append('suchmuch')
+ result.append('much')
else:
result.append(str(i))
return result;
def count_doge_words(sentence):
bad_words = {'wow', 'lol', 'so', 'such', 'much'}
words = sentence.split()
bad_words_count = 0
for word in words:
if word in bad_words:
bad_words_count += 1
return bad_words_count

Александър обнови решението на 09.03.2014 00:49 (преди над 10 години)

def wow_such_much(start, end):
result = []
for i in range(start, end):
- if i % 3 == 0 and i % 5 == 0:
+ if i % 15 == 0:
result.append('suchmuch')
elif i % 3 == 0:
result.append('such')
elif i % 5 == 0:
result.append('much')
else:
result.append(str(i))
return result;
def count_doge_words(sentence):
bad_words = {'wow', 'lol', 'so', 'such', 'much'}
words = sentence.split()
bad_words_count = 0
for word in words:
if word in bad_words:
bad_words_count += 1
- return bad_words_count
+ return bad_words_count