Решение на doge от Минх Нгуен

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

Към профила на Минх Нгуен

Резултати

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

Код

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

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

F..F..F.....FFF
======================================================================
FAIL: test_sentence_with_parasite_word_as_part_of_normal_one (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-z95wrl/test.py", line 52, in test_sentence_with_parasite_word_as_part_of_normal_one
    self.assertEqual(2, solution.count_doge_words("wow soon hard such difficult"))
AssertionError: 2 != 3

======================================================================
FAIL: test_with_glued_parasite_words (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-z95wrl/test.py", line 61, in test_with_glued_parasite_words
    self.assertEqual(0, solution.count_doge_words('wowlolsosuchmuchvery'))
AssertionError: 0 != 6

======================================================================
FAIL: test_with_repeating_parasite_words (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-z95wrl/test.py", line 64, in test_with_repeating_parasite_words
    self.assertEqual(5, solution.count_doge_words('wow hard wow much such difficult much'))
AssertionError: 5 != 3

======================================================================
FAIL: test_suchmuch_to_100 (test.TestSuchMuchDoge)
----------------------------------------------------------------------
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-z95wrl/test.py", line 38, in test_suchmuch_to_100
    '92', 'such', '94', 'much', 'such', '97', '98', 'such'])
AssertionError: Lists differ: [1, 2, 'such', 4, 'much', 'suc... != ['1', '2', 'such', '4', 'much'...

First differing element 0:
1
1

Diff is 1798 characters long. Set self.maxDiff to None to see it.

======================================================================
FAIL: test_suchmuch_to_16 (test.TestSuchMuchDoge)
----------------------------------------------------------------------
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-z95wrl/test.py", line 20, in test_suchmuch_to_16
    '11', 'such', '13', '14', 'suchmuch'])
AssertionError: Lists differ: [1, 2, 'such', 4, 'much', 'suc... != ['1', '2', 'such', '4', 'much'...

First differing element 0:
1
1

- [1,
+ ['1',
?  + +

-  2,
+  '2',
?  + +

   'such',
-  4,
+  '4',
?  + +

   'much',
   'such',
-  7,
+  '7',
?  + +

-  8,
+  '8',
?  + +

   'such',
   'much',
-  11,
+  '11',
?  +  +

   'such',
-  13,
+  '13',
?  +  +

-  14,
+  '14',
?  +  +

-  'such']
+  'suchmuch']
?       ++++


======================================================================
FAIL: test_suchmuch_to_2 (test.TestSuchMuchDoge)
----------------------------------------------------------------------
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-z95wrl/test.py", line 14, in test_suchmuch_to_2
    self.assertEqual(solution.wow_such_much(1, 2), ['1'])
AssertionError: Lists differ: [1] != ['1']

First differing element 0:
1
1

- [1]
+ ['1']
?  + +


----------------------------------------------------------------------
Ran 15 tests in 0.045s

FAILED (failures=6)

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

Минх обнови решението на 11.03.2014 18:32 (преди над 10 години)

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