Решение на doge от Теодор Халваджиев

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

Към профила на Теодор Халваджиев

Резултати

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

Код

def wow_such_much(start, end):
doge_list = []
for i in range(start, end):
if i % 3 == 0 :
if i % 5 == 0 :
doge_list.append ("suchmuch")
else :
doge_list.append ("such")
elif i % 5 == 0:
doge_list.append("much")
else : doge_list.append(str(i))
return doge_list
def count_doge_words(input_string):
banned_words= ["wow", "lol", "so", "such", "much", "very"]
split_string = input_string.split()
return sum(1 for word in split_string if word in banned_words)

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

...............
----------------------------------------------------------------------
Ran 15 tests in 0.009s

OK

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

Теодор обнови решението на 06.03.2014 22:34 (преди над 10 години)

+
+
+def wow_such_much(start, end):
+
+ spisuk = []
+
+ for i in range(start, end):
+ spisuk.append(i)
+
+ for i in range(0, len(spisuk)):
+ if spisuk[i] % 3 == 0 :
+ if spisuk[i] % 5 == 0 :
+ spisuk[i] = "suchmuch"
+ else :
+ spisuk[i] = "such"
+ elif spisuk[i] % 5 == 0:
+ spisuk[i] = "much"
+ else : spisuk[i] = str(spisuk[i])
+
+ return spisuk
+
+def count_doge_words(inputString):
+ bannedWords = ["wow", "lol", "so", "such", "much", "very"]
+ numberOfBannedWords = 0
+
+ for word in bannedWords:
+ i = 0
+
+ while i < len(inputString):
+
+ rightNill = inputString[i : len(inputString)].find(word) + len(word) == len(inputString)
+
+ if rightNill == False:
+ rightSpace = inputString[inputString[i : len(inputString)].find(word) + len(word)] == " "
+
+
+ leftSpace = inputString[inputString[i : len(inputString)].find(word) - 1] == " "
+
+ leftNill = inputString[i : len(inputString)].find(word) == 0
+
+ if word in inputString[i : len(inputString)]:
+
+ if (rightSpace or rightNill) and (leftSpace or leftNill):
+
+ i += len(word) + inputString[i : len(inputString)].find(word)
+ numberOfBannedWords += 1
+
+ i +=1
+ return numberOfBannedWords
+
+
+
+
  • Погледни конвенцията за имената на променливите в Python
  • spisuk не е особено добро име, опитай се да го замениш с нещо, което валидна дума в английския
  • В момента още си под влиянието на други езици, опитай се да пишеш повече в стила на Python. Погледни какви методи имат типовете, които използваш, може да ти е от полза

Теодор обнови решението на 07.03.2014 13:21 (преди над 10 години)

def wow_such_much(start, end):
-
- spisuk = []
-
+
+ doge_list = []
+
for i in range(start, end):
- spisuk.append(i)
-
- for i in range(0, len(spisuk)):
- if spisuk[i] % 3 == 0 :
- if spisuk[i] % 5 == 0 :
- spisuk[i] = "suchmuch"
- else :
- spisuk[i] = "such"
- elif spisuk[i] % 5 == 0:
- spisuk[i] = "much"
- else : spisuk[i] = str(spisuk[i])
-
- return spisuk
+ doge_list.append(i)
-def count_doge_words(inputString):
- bannedWords = ["wow", "lol", "so", "such", "much", "very"]
- numberOfBannedWords = 0
-
- for word in bannedWords:
- i = 0
-
- while i < len(inputString):
-
- rightNill = inputString[i : len(inputString)].find(word) + len(word) == len(inputString)
-
- if rightNill == False:
- rightSpace = inputString[inputString[i : len(inputString)].find(word) + len(word)] == " "
-
-
- leftSpace = inputString[inputString[i : len(inputString)].find(word) - 1] == " "
-
- leftNill = inputString[i : len(inputString)].find(word) == 0
-
- if word in inputString[i : len(inputString)]:
-
- if (rightSpace or rightNill) and (leftSpace or leftNill):
-
- i += len(word) + inputString[i : len(inputString)].find(word)
- numberOfBannedWords += 1
-
- i +=1
- return numberOfBannedWords
-
-
+ for i in range(0, len(doge_list)):
+ if doge_list[i] % 3 == 0 :
+ if doge_list[i] % 5 == 0 :
+ doge_list[i] = "suchmuch"
+ else :
+ doge_list[i] = "such"
+ elif doge_list[i] % 5 == 0:
+ doge_list[i] = "much"
+ else : doge_list[i] = str(doge_list[i])
+
+ return doge_list
+
+def count_doge_words(input_string):
+ banned_words= ["wow", "lol", "so", "such", "much", "very"]
+ number_of_banned_words = 0
+ split_string = input_string.split()
-
+ for word in split_string:
+ if word in banned_words:
+ number_of_banned_words += 1
+
+ return number_of_banned_words
+
+
+

Теодор обнови решението на 07.03.2014 23:34 (преди над 10 години)

-
-
def wow_such_much(start, end):
doge_list = []
for i in range(start, end):
- doge_list.append(i)
-
- for i in range(0, len(doge_list)):
- if doge_list[i] % 3 == 0 :
- if doge_list[i] % 5 == 0 :
- doge_list[i] = "suchmuch"
+ if i % 3 == 0 :
+ if i % 5 == 0 :
+ doge_list.append ("suchmuch")
else :
- doge_list[i] = "such"
- elif doge_list[i] % 5 == 0:
- doge_list[i] = "much"
- else : doge_list[i] = str(doge_list[i])
+ doge_list.append ("such")
+ elif i % 5 == 0:
+ doge_list.append("much")
+ else : doge_list.append(str(i))
return doge_list
def count_doge_words(input_string):
banned_words= ["wow", "lol", "so", "such", "much", "very"]
number_of_banned_words = 0
split_string = input_string.split()
for word in split_string:
if word in banned_words:
number_of_banned_words += 1
return number_of_banned_words
-
+print(count_doge_words("wow such much"))

Теодор обнови решението на 09.03.2014 19:40 (преди над 10 години)

+
+
def wow_such_much(start, end):
doge_list = []
for i in range(start, end):
if i % 3 == 0 :
if i % 5 == 0 :
doge_list.append ("suchmuch")
else :
doge_list.append ("such")
elif i % 5 == 0:
doge_list.append("much")
else : doge_list.append(str(i))
return doge_list
def count_doge_words(input_string):
banned_words= ["wow", "lol", "so", "such", "much", "very"]
- number_of_banned_words = 0
split_string = input_string.split()
-
- for word in split_string:
- if word in banned_words:
- number_of_banned_words += 1
-
- return number_of_banned_words
+ return sum(1 for word in split_string if word in banned_words)
-print(count_doge_words("wow such much"))
+