Решение на doge от Цветислав Викторов

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

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

Резултати

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

Код

arguments = []
def wow_such_much(start, end):
for i in range(start, end+1):
if i%3 == 0 and i%5 == 0:
arguments.append('suchmmuch')
elif i%3 == 0:
arguments.append('such')
elif i%5 ==0:
arguments.append('much')
else:
arguments.append(str(i))
return arguments
PARASITES = ['wow', 'lol', 'so', 'such', 'much', 'very']
def count_doge_words(string):
words = string.split()
counter = 0
for word in words:
if word in PARASITES:
counter = counter + 1
return counter

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

.........FFFFFF
======================================================================
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-183hf9x/test.py", line 23, in test_suchmuch_from_16_to_16
    self.assertEqual(solution.wow_such_much(16, 16), [])
AssertionError: Lists differ: ['16'] != []

First list contains 1 additional elements.
First extra element 0:
16

- ['16']
+ []

======================================================================
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-183hf9x/test.py", line 8, in test_suchmuch_to_0
    self.assertEqual(solution.wow_such_much(1, 0), [])
AssertionError: Lists differ: ['16'] != []

First list contains 1 additional elements.
First extra element 0:
16

- ['16']
+ []

======================================================================
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-183hf9x/test.py", line 11, in test_suchmuch_to_1
    self.assertEqual(solution.wow_such_much(1, 1), [])
AssertionError: Lists differ: ['16', '1'] != []

First list contains 2 additional elements.
First extra element 0:
16

- ['16', '1']
+ []

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

First differing element 0:
16
1

First list contains 3 additional elements.
First extra element 99:
98

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

First differing element 0:
16
1

First list contains 103 additional elements.
First extra element 15:
14

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

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

First differing element 0:
16
1

First list contains 119 additional elements.
First extra element 1:
1

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

----------------------------------------------------------------------
Ran 15 tests in 0.037s

FAILED (failures=6)

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

Цветислав обнови решението на 11.03.2014 21:35 (преди над 10 години)

+my_list = []
+def wow_such_much(start, end):
+ for i in range(start, end+1):
+ if i%3 == 0 and i%5 == 0:
+ my_list.append("suchmuch")
+ elif i%3 == 0:
+ my_list.append("such")
+ elif i%5 == 0:
+ my_list.append("much")
+ else:
+ my_list.append(i)
+
+ return my_list
+
+parasites = ["wow", "lol", "so", "such", "much", "very"]
+
+def count_doge_words(string):
+ arr=string.split()
+ arr2 = []
+ counter = 0
+ for i in range(0,len(arr)):
+ for j in range(0,len(parasites)):
+ if arr[i] == parasites[j]:
+ counter = counter
+ return counter
  • Не идентираш с 4 интеревала
  • my_list, arr и arr2 са ужасни имена на променливи
  • Константите се пишат в SCREAMING_SNAKE_CASE
  • Обърни внимание, че и числата са стрингове в wow_such_much
  • Опитай се да решиш count_doge_words без два вложени for цикли

Цветислав обнови решението на 12.03.2014 12:34 (преди над 10 години)

-my_list = []
+arguments = []
def wow_such_much(start, end):
- for i in range(start, end+1):
- if i%3 == 0 and i%5 == 0:
- my_list.append("suchmuch")
- elif i%3 == 0:
- my_list.append("such")
- elif i%5 == 0:
- my_list.append("much")
- else:
- my_list.append(i)
-
- return my_list
+ for i in range(start, end+1):
+ if i%3 == 0 and i%5 == 0:
+ arguments.append('suchmmuch')
+ elif i%3 == 0:
+ arguments.append('such')
+ elif i%5 ==0:
+ arguments.append('much')
+ else:
+ arguments.append(str(i))
+ return arguments
-parasites = ["wow", "lol", "so", "such", "much", "very"]
+PARASITES = ['wow', 'lol', 'so', 'such', 'much', 'very']
def count_doge_words(string):
- arr=string.split()
- arr2 = []
+ words = string.split()
- counter = 0
+ counter = 0
- for i in range(0,len(arr)):
+ for word in words:
- for j in range(0,len(parasites)):
+ if word in PARASITES:
- if arr[i] == parasites[j]:
+ counter = counter + 1
- counter = counter
+ return counter
- return counter
+