Решение на doge от Цветан Чипилски

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

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

Резултати

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

Код

def wow_such_much(start,end):
nums = []
for i in range(start,end):
if i%3 == 0 and i%5 ==0:
i = "suchmuch"
nums.append(i)
elif i%5 == 0:
i = "much"
nums.append(i)
elif i%3 == 0:
i = "such"
nums.append(i)
else:
nums.append(i)
print(nums)
def count_doge_words(text):
count = 0
words = text.split()
for word in words:
if word == "wow" or word == "lol" or word == "so" or word == "such" or word =="much" or word =="very":
count = count+1
print(count)

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

F
Stdout:
2
F
Stdout:
0
F
Stdout:
0
F
Stdout:
0
F
Stdout:
6
F
Stdout:
6
F
Stdout:
5
F
Stdout:
3
F
Stdout:
[]
F
Stdout:
[]
F
Stdout:
[]
F
Stdout:
[]
F
Stdout:
[1, 2, 'such', 4, 'much', 'such', 7, 8, 'such', 'much', 11, 'such', 13, 14, 'suchmuch', 16, 17, 'such', 19, 'much', 'such', 22, 23, 'such', 'much', 26, 'such', 28, 29, 'suchmuch', 31, 32, 'such', 34, 'much', 'such', 37, 38, 'such', 'much', 41, 'such', 43, 44, 'suchmuch', 46, 47, 'such', 49, 'much', 'such', 52, 53, 'such', 'much', 56, 'such', 58, 59, 'suchmuch', 61, 62, 'such', 64, 'much', 'such', 67, 68, 'such', 'much', 71, 'such', 73, 74, 'suchmuch', 76, 77, 'such', 79, 'much', 'such', 82, 83, 'such', 'much', 86, 'such', 88, 89, 'suchmuch', 91, 92, 'such', 94, 'much', 'such', 97, 98, 'such']
F
Stdout:
[1, 2, 'such', 4, 'much', 'such', 7, 8, 'such', 'much', 11, 'such', 13, 14, 'suchmuch']
F
Stdout:
[1]

======================================================================
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-1yd5gic/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 != None

Stdout:
2

======================================================================
FAIL: 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-1yd5gic/test.py", line 49, in test_sentence_without_slangs
    self.assertEqual(0, solution.count_doge_words("The quick brown fox jumps over"))
AssertionError: 0 != None

Stdout:
0

======================================================================
FAIL: 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-1yd5gic/test.py", line 55, in test_with_empty_sentence
    self.assertEqual(0, solution.count_doge_words(""))
AssertionError: 0 != None

Stdout:
0

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

Stdout:
0

======================================================================
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-1yd5gic/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 != None

Stdout:
6

======================================================================
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-1yd5gic/test.py", line 58, in test_with_parasite_sentence
    self.assertEqual(6, solution.count_doge_words('wow lol so such much very'))
AssertionError: 6 != None

Stdout:
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-1yd5gic/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 != None

Stdout:
5

======================================================================
FAIL: 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-1yd5gic/test.py", line 46, in test_with_simple_sentence
    self.assertEqual(3, solution.count_doge_words("wow much hard such difficult"))
AssertionError: 3 != None

Stdout:
3

======================================================================
FAIL: test_negative_suchmuch (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-1yd5gic/test.py", line 41, in test_negative_suchmuch
    self.assertEqual(solution.wow_such_much(16, 1), [])
AssertionError: None != []

Stdout:
[]

======================================================================
FAIL: test_suchmuch_from_16_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-1yd5gic/test.py", line 23, in test_suchmuch_from_16_to_16
    self.assertEqual(solution.wow_such_much(16, 16), [])
AssertionError: None != []

Stdout:
[]

======================================================================
FAIL: test_suchmuch_to_0 (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-1yd5gic/test.py", line 8, in test_suchmuch_to_0
    self.assertEqual(solution.wow_such_much(1, 0), [])
AssertionError: None != []

Stdout:
[]

======================================================================
FAIL: test_suchmuch_to_1 (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-1yd5gic/test.py", line 11, in test_suchmuch_to_1
    self.assertEqual(solution.wow_such_much(1, 1), [])
AssertionError: None != []

Stdout:
[]

======================================================================
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-1yd5gic/test.py", line 38, in test_suchmuch_to_100
    '92', 'such', '94', 'much', 'such', '97', '98', 'such'])
AssertionError: None != ['1', '2', 'such', '4', 'much', 'such', '7', '8', 'such', 'much', '11', 'such', '13', '14', 'suchmuch', '16', '17', 'such', '19', 'much', 'such', '22', '23', 'such', 'much', '26', 'such', '28', '29', 'suchmuch', '31', '32', 'such', '34', 'much', 'such', '37', '38', 'such', 'much', '41', 'such', '43', '44', 'suchmuch', '46', '47', 'such', '49', 'much', 'such', '52', '53', 'such', 'much', '56', 'such', '58', '59', 'suchmuch', '61', '62', 'such', '64', 'much', 'such', '67', '68', 'such', 'much', '71', 'such', '73', '74', 'suchmuch', '76', '77', 'such', '79', 'much', 'such', '82', '83', 'such', 'much', '86', 'such', '88', '89', 'suchmuch', '91', '92', 'such', '94', 'much', 'such', '97', '98', 'such']

Stdout:
[1, 2, 'such', 4, 'much', 'such', 7, 8, 'such', 'much', 11, 'such', 13, 14, 'suchmuch', 16, 17, 'such', 19, 'much', 'such', 22, 23, 'such', 'much', 26, 'such', 28, 29, 'suchmuch', 31, 32, 'such', 34, 'much', 'such', 37, 38, 'such', 'much', 41, 'such', 43, 44, 'suchmuch', 46, 47, 'such', 49, 'much', 'such', 52, 53, 'such', 'much', 56, 'such', 58, 59, 'suchmuch', 61, 62, 'such', 64, 'much', 'such', 67, 68, 'such', 'much', 71, 'such', 73, 74, 'suchmuch', 76, 77, 'such', 79, 'much', 'such', 82, 83, 'such', 'much', 86, 'such', 88, 89, 'suchmuch', 91, 92, 'such', 94, 'much', 'such', 97, 98, 'such']

======================================================================
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-1yd5gic/test.py", line 20, in test_suchmuch_to_16
    '11', 'such', '13', '14', 'suchmuch'])
AssertionError: None != ['1', '2', 'such', '4', 'much', 'such', '7', '8', 'such', 'much', '11', 'such', '13', '14', 'suchmuch']

Stdout:
[1, 2, 'such', 4, 'much', 'such', 7, 8, 'such', 'much', 11, 'such', 13, 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-1yd5gic/test.py", line 14, in test_suchmuch_to_2
    self.assertEqual(solution.wow_such_much(1, 2), ['1'])
AssertionError: None != ['1']

Stdout:
[1]

----------------------------------------------------------------------
Ran 15 tests in 0.015s

FAILED (failures=15)

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

Цветан обнови решението на 12.03.2014 14:36 (преди над 10 години)

+def wow_such_much(start,end):
+ nums = []
+ for i in range(start,end):
+ if i%3 == 0 and i%5 ==0:
+ i = "suchmuch"
+ nums.append(i)
+
+ elif i%5 == 0:
+ i = "much"
+ nums.append(i)
+
+ elif i%3 == 0:
+ i = "such"
+ nums.append(i)
+
+ else:
+ nums.append(i)
+ print(nums)
+
+
+
+def count_doge_words(text):
+ count = 0
+ words = text.split()
+ for word in words:
+ if word == "wow" or word == "lol" or word == "so" or word == "such" or word =="much" or word =="very":
+ count = count+1
+ print(count)
  • Идентирай с 4 интервала
  • Функциите ти връщат None, а не това, което е упоменато в условието
  • Този if не е ок: if word == "wow" or word == "lol" or word == "so" or word == "such" or word =="much" or word =="very":. Представи си, че ви дадем 64 doge words.
  • count = count+1 може да се опрости до count += 1
  • Прочети внимателно PEP 8
  • Прочети внимателно указанията за предаване на домашни