Решение на doge от Цветомир Цанов

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

Към профила на Цветомир Цанов

Резултати

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

Код

def wow_such_much(start, end):
k = 0
list1 = []
for i in range(start, end):
if i%3 == 0 and i%5 == 0:
list1.insert(k,"suchmuch")
k+=1
elif i%3 == 0:
list1.insert(k,"such")
k+=1
elif i%5 == 0:
list1.insert(k,"much")
k+=1
else:
list1.insert(k,i)
k+=1
return list1
def count_doge_words(word):
list2 = ["wow", "lol", "so", "such", "much", "very"]
count = 0
for i in range(0,6):
if word.find(list2[i], 0) >= 0:
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-2kswtx/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-2kswtx/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-2kswtx/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-2kswtx/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 1840 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-2kswtx/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',
?  +  +

   '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-2kswtx/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 версия и 2 коментара)

Цветомир обнови решението на 12.03.2014 16:31 (преди около 10 години)

+def wow_such_much(start, end):
+ k = 0
+ list1 = []
+ for i in range(start, end):
+ if i%3 == 0 and i%5 == 0:
+ list1.insert(k,"suchmuch")
+ k+=1
+ elif i%3 == 0:
+ list1.insert(k,"such")
+ k+=1
+ elif i%5 == 0:
+ list1.insert(k,"much")
+ k+=1
+
+ else:
+ list1.insert(k,i)
+ k+=1
+ return list1
+
+def count_doge_words(word):
+ list2 = ["wow", "lol", "so", "such", "much", "very"]
+ count = 0
+ for i in range(0,6):
+ if word.find(list2[i], 0) >= 0:
+ count+=1
+ return count