Решение на doge от Константин Паенов

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

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

Резултати

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

Код

#!/usr/bin/python3.3
import re
def wow_such_much(start, end):
doge_list = []
for i in range(start, end):
a = i/3 - i//3
b = i/5 - i//5
if a == 0 and b == 0:
doge_list.append("suchmuch")
elif a == 0:
doge_list.append("such")
elif b == 0:
doge_list.append("much")
else:
doge_list.append(repr(i))
return(doge_list)
def count_doge_words(sentence):
words = ['wow', 'lol', 'so', 'such', 'much', 'very']
words_found = []
all_words = sentence.split()
i = 0
for word in words:
if word in all_words:
i += 1
return (i)

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

......F........
======================================================================
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-9etwoa/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

----------------------------------------------------------------------
Ran 15 tests in 0.008s

FAILED (failures=1)

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

Константин обнови решението на 11.03.2014 23:15 (преди над 10 години)

+#!/usr/bin/python3.3
+import re
+
+def wow_such_much(start, end):
+ doge_list = []
+ for i in range(start, end):
+ a = i/3 - i//3
+ b = i/5 - i//5
+ if a == 0 and b == 0:
+ doge_list.append("suchmuch")
+ elif a == 0:
+ doge_list.append("such")
+ elif b == 0:
+ doge_list.append("much")
+ else:
+ doge_list.append(repr(i))
+ return(doge_list)
+
+
+def count_doge_words(sentence):
+ words = ['wow', 'lol', 'so', 'such', 'much', 'very']
+ words_found = []
+ all_words = re.findall(r'\w+', sentence)
+ i = 0
+ for word in words:
+ if word in all_words:
+ i += 1
+ return (i)

Константин обнови решението на 11.03.2014 23:30 (преди над 10 години)

#!/usr/bin/python3.3
import re
def wow_such_much(start, end):
doge_list = []
for i in range(start, end):
a = i/3 - i//3
b = i/5 - i//5
if a == 0 and b == 0:
doge_list.append("suchmuch")
elif a == 0:
doge_list.append("such")
elif b == 0:
doge_list.append("much")
else:
doge_list.append(repr(i))
return(doge_list)
def count_doge_words(sentence):
words = ['wow', 'lol', 'so', 'such', 'much', 'very']
words_found = []
- all_words = re.findall(r'\w+', sentence)
+ all_words = sentence.split()
i = 0
for word in words:
if word in all_words:
i += 1
return (i)