Решение на doge от Джована Аспарухова

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

Към профила на Джована Аспарухова

Резултати

  • 3 точки от тестове
  • 2 отнети точки
  • 1 точка общо
  • 5 успешни тест(а)
  • 10 неуспешни тест(а)

Код

def wow_such_much(start,end):
my_list=[]
my_list=list()
x=start-1
y=end-1
for i in range(x,y):
x=x+1
if(x%3==0):
my_list.append('such')
elif(x%5==0):
my_list.append('much')
elif(x%3==0 and x%5==0):
my_list.append(str('suchmuch'))
else:
my_list.append(str(x))
return my_list

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

EEEEEEEE....FF.
======================================================================
ERROR: 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-m6a801/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"))
AttributeError: 'module' object has no attribute 'count_doge_words'

======================================================================
ERROR: test_sentence_without_slangs (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-m6a801/test.py", line 49, in test_sentence_without_slangs
    self.assertEqual(0, solution.count_doge_words("The quick brown fox jumps over"))
AttributeError: 'module' object has no attribute 'count_doge_words'

======================================================================
ERROR: test_with_empty_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-m6a801/test.py", line 55, in test_with_empty_sentence
    self.assertEqual(0, solution.count_doge_words(""))
AttributeError: 'module' object has no attribute 'count_doge_words'

======================================================================
ERROR: 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-m6a801/test.py", line 61, in test_with_glued_parasite_words
    self.assertEqual(0, solution.count_doge_words('wowlolsosuchmuchvery'))
AttributeError: 'module' object has no attribute 'count_doge_words'

======================================================================
ERROR: 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-m6a801/test.py", line 67, in test_with_more_space_between_parasites
    self.assertEqual(6, solution.count_doge_words('wow  lol    so  such   much      very'))
AttributeError: 'module' object has no attribute 'count_doge_words'

======================================================================
ERROR: 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-m6a801/test.py", line 58, in test_with_parasite_sentence
    self.assertEqual(6, solution.count_doge_words('wow lol so such much very'))
AttributeError: 'module' object has no attribute 'count_doge_words'

======================================================================
ERROR: 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-m6a801/test.py", line 64, in test_with_repeating_parasite_words
    self.assertEqual(5, solution.count_doge_words('wow hard wow much such difficult much'))
AttributeError: 'module' object has no attribute 'count_doge_words'

======================================================================
ERROR: test_with_simple_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-m6a801/test.py", line 46, in test_with_simple_sentence
    self.assertEqual(3, solution.count_doge_words("wow much hard such difficult"))
AttributeError: 'module' object has no attribute 'count_doge_words'

======================================================================
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-m6a801/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'... != ['1', '2', 'such', '4', 'much'...

First differing element 14:
such
suchmuch

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

First differing element 14:
such
suchmuch

  ['1',
   '2',
   'such',
   '4',
   'much',
   'such',
   '7',
   '8',
   'such',
   'much',
   '11',
   'such',
   '13',
   '14',
-  'such']
+  'suchmuch']
?       ++++


----------------------------------------------------------------------
Ran 15 tests in 0.026s

FAILED (failures=2, errors=8)

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

Джована обнови решението на 12.03.2014 15:03 (преди над 10 години)

+def wow_such_much(start,end):
+ my_list=[]
+ my_list=list()
+ x=start-1
+ y=end-1
+ for i in range(x,y):
+ x=x+1
+ if(x%3==0):
+ my_list.append('such')
+ elif(x%5==0):
+ my_list.append('much')
+ elif(x%3==0 and x%5==0):
+ my_list.append(str('suchmuch'))
+ else:
+ my_list.append(str(x))
+ return my_list
  • Пусни си примерните тестове. Има инструкции във темата за домашното и тук: http://fmi.py-bg.net/tasks/guide (ще си видиш грешките)
    • в elif(x%3==0 and x%5==0): никога няма да влезеш
  • скобите около условието на if-овете са излишни
  • 'suchmuch' си е низ, няма нужда да го кастваш