Решение на doge от Марианна Владимирова

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

Към профила на Марианна Владимирова

Резултати

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

Код

def wow_such_much(start,end):
doge_numbers = []
for i in range (start,end):
if i%15 == 0:
doge_numbers.append('suchmuch')
elif i%5 == 0:
doge_numbers.append('much')
elif i%3 == 0:
doge_numbers.append('such')
else:
doge_numbers.append(str(i))
return doge_numbers
def count_doge_words(words):
words_count = 0
space_index = words.find(' ')
i = 0
while i < space_index:
if 'wow' in words:
words_count += 1
elif 'lol' in words:
words_count += 1
elif 'so' in words:
words_count += 1
elif 'such' in words:
words_count += 1
elif 'much' in words:
words_count += 1
elif 'very' in words:
words_count += 1
space_index=words.find(' ')
i += 1
return words_count

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

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-1678u6h/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_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-1678u6h/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 != 3

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

======================================================================
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-1678u6h/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.009s

FAILED (failures=4)

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

Марианна обнови решението на 08.03.2014 15:50 (преди около 10 години)

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

Марианна обнови решението на 08.03.2014 18:15 (преди около 10 години)

def wow_such_much(start,end):
my_list = []
for i in range(start,end):
if i%3==0 and i%5==0:
my_list.append('suchmuch')
elif i%5==0:
my_list.append('much')
elif i%3==0:
my_list.append('such')
else:
my_list.append(str(i))
- return my_list
+ return my_list
+
+def count_doge_words(words):
+ count=0
+ space = words.find(' ')
+ i=0
+ while i<space:
+ if 'wow' in words:
+ count+=1
+ elif 'lol' in words:
+ count+=1
+ elif 'so' in words:
+ count+=1
+ elif 'such' in words:
+ count+=1
+ elif 'much' in words:
+ count+=1
+ elif 'very' in words:
+ count+=1
+ space = words.find(' ')
+ i+=1
+ return count
  • Опитай се да опростиш това условие i%3==0 and i%5==0
  • Търсенето на думи в count_doge_words е твърде наивно и може да върне истина по грешка. Можеш ли да се сетиш защо?
  • Именоваш си променливите лошо.
  • Използваш идентация различна от 4 интервала

Марианна обнови решението на 09.03.2014 17:59 (преди около 10 години)

def wow_such_much(start,end):
- my_list = []
- for i in range(start,end):
- if i%3==0 and i%5==0:
- my_list.append('suchmuch')
- elif i%5==0:
- my_list.append('much')
- elif i%3==0:
- my_list.append('such')
- else:
- my_list.append(str(i))
- return my_list
+ my_list=[]
+ for i in range (start,end):
+ if i%15==0:
+ my_list.append('suchmuch')
+ elif i%5==0:
+ my_list.append('much')
+ elif i%3==0:
+ my_list.append('such')
+ else:
+ my_list.append(str(i))
+ return my_list
+
def count_doge_words(words):
- count=0
- space = words.find(' ')
+ words_count=0
- i=0
+ space_index = words.find(' ')
- while i<space:
+ i=0
- if 'wow' in words:
+ while i <space_index:
- count+=1
+ if 'wow' in words:
- elif 'lol' in words:
+ words_count +=1
- count+=1
+ elif 'lol' in words:
- elif 'so' in words:
+ words_count+=1
- count+=1
+ elif 'so' in words:
- elif 'such' in words:
+ words_count+=1
- count+=1
+ elif 'such' in words:
- elif 'much' in words:
+ words_count+=1
- count+=1
+ elif 'much' in words:
- elif 'very' in words:
+ words_count+=1
- count+=1
+ elif 'very' in words:
- space = words.find(' ')
+ words_count+=1
- i+=1
+ space_index=words.find(' ')
- return count
+ i+=1
+ return words_count

Марианна обнови решението на 11.03.2014 23:12 (преди около 10 години)

def wow_such_much(start,end):
- my_list=[]
+ doge_numbers=[]
for i in range (start,end):
if i%15==0:
- my_list.append('suchmuch')
+ doge_numbers.append('suchmuch')
elif i%5==0:
- my_list.append('much')
+ doge_numbers.append('much')
elif i%3==0:
- my_list.append('such')
+ doge_numbers.append('such')
else:
- my_list.append(str(i))
- return my_list
+ doge_numbers.append(str(i))
+ return doge_numbers
def count_doge_words(words):
words_count=0
space_index = words.find(' ')
i=0
while i <space_index:
if 'wow' in words:
words_count +=1
elif 'lol' in words:
words_count+=1
elif 'so' in words:
words_count+=1
elif 'such' in words:
words_count+=1
elif 'much' in words:
words_count+=1
elif 'very' in words:
words_count+=1
space_index=words.find(' ')
i+=1
return words_count

Марианна обнови решението на 12.03.2014 14:28 (преди около 10 години)

def wow_such_much(start,end):
- doge_numbers=[]
+ doge_numbers = []
for i in range (start,end):
- if i%15==0:
+ if i%15 == 0:
doge_numbers.append('suchmuch')
- elif i%5==0:
+ elif i%5 == 0:
doge_numbers.append('much')
- elif i%3==0:
+ elif i%3 == 0:
doge_numbers.append('such')
else:
doge_numbers.append(str(i))
return doge_numbers
def count_doge_words(words):
- words_count=0
+ words_count = 0
space_index = words.find(' ')
- i=0
- while i <space_index:
+ i = 0
+ while i < space_index:
if 'wow' in words:
- words_count +=1
+ words_count += 1
elif 'lol' in words:
- words_count+=1
+ words_count += 1
elif 'so' in words:
- words_count+=1
+ words_count += 1
elif 'such' in words:
- words_count+=1
+ words_count += 1
elif 'much' in words:
- words_count+=1
+ words_count += 1
elif 'very' in words:
- words_count+=1
+ words_count += 1
space_index=words.find(' ')
- i+=1
+ i += 1
return words_count