Решение на doge от Мария Кърчева

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

Към профила на Мария Кърчева

Резултати

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

Код

import re
def wow_such_much(start, end):
numbers = [i for i in range(start, end)]
strings = []
for num in numbers:
if num % 3 == 0 and num % 5 == 0:
strings.append("suchmuch")
elif num % 3 == 0:
strings.append("such")
elif num % 5 == 0:
strings.append("much")
else:
strings.append(str(num))
return strings
def count_doge_words(statement):
words = statement.split()
regex = r"^(wow|lol|so|such|much|very)$"
doge_words = [word for word in words if re.match(regex, word)]
return len(doge_words)

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

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

OK

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

Мария обнови решението на 11.03.2014 14:20 (преди над 10 години)

+def wow_such_much(start, end):
+ numbers = [num for num in range(start, end)]
+ for i in range(0, end - start):
+ if numbers[i] % 3 == 0 and numbers[i] % 5 == 0:
+ numbers[i] = "suchmuch"
+ elif numbers[i] % 3 == 0:
+ numbers[i] = "such"
+ elif numbers[i] % 5 == 0:
+ numbers[i] = "much"
+ else:
+ numbers[i] = str(numbers[i])
+ return numbers
+def count_doge_words(statement):
+ doge_words = []
+ words = statement.split()
+ for word in words:
+ if (word == "wow" or word == "lol" or word == "so" or word == "such" or
+ word == "much" or word == "very"):
+ doge_words.append(word)
+ return len(doge_words)

Мария обнови решението на 11.03.2014 15:34 (преди над 10 години)

+import re
def wow_such_much(start, end):
- numbers = [num for num in range(start, end)]
- for i in range(0, end - start):
- if numbers[i] % 3 == 0 and numbers[i] % 5 == 0:
- numbers[i] = "suchmuch"
- elif numbers[i] % 3 == 0:
- numbers[i] = "such"
- elif numbers[i] % 5 == 0:
- numbers[i] = "much"
- else:
- numbers[i] = str(numbers[i])
- return numbers
+ numbers = [num for num in range(start, end)]
+ for i in range(0, end - start):
+ if numbers[i] % 3 == 0 and numbers[i] % 5 == 0:
+ numbers[i] = "suchmuch"
+ elif numbers[i] % 3 == 0:
+ numbers[i] = "such"
+ elif numbers[i] % 5 == 0:
+ numbers[i] = "much"
+ else:
+ numbers[i] = str(numbers[i])
+ return numbers
+
def count_doge_words(statement):
- doge_words = []
- words = statement.split()
+ words = statement.split()
- for word in words:
+ regex = r"^(wow|lol|so|such|much|very)$"
- if (word == "wow" or word == "lol" or word == "so" or word == "such" or
+ doge_words = [word for word in words if re.match(regex, word)]
- word == "much" or word == "very"):
+ return len(doge_words)
- doge_words.append(word)
- return len(doge_words)

Мария обнови решението на 11.03.2014 22:51 (преди над 10 години)

import re
def wow_such_much(start, end):
- numbers = [num for num in range(start, end)]
- for i in range(0, end - start):
- if numbers[i] % 3 == 0 and numbers[i] % 5 == 0:
- numbers[i] = "suchmuch"
- elif numbers[i] % 3 == 0:
- numbers[i] = "such"
- elif numbers[i] % 5 == 0:
- numbers[i] = "much"
+ numbers = [i for i in range(start, end)]
+ strings = []
+ for num in numbers:
+ if num % 3 == 0 and num % 5 == 0:
+ strings.append("suchmuch")
+ elif num % 3 == 0:
+ strings.append("such")
+ elif num % 5 == 0:
+ strings.append("much")
else:
- numbers[i] = str(numbers[i])
- return numbers
+ strings.append(str(num))
+ return strings
def count_doge_words(statement):
words = statement.split()
regex = r"^(wow|lol|so|such|much|very)$"
doge_words = [word for word in words if re.match(regex, word)]
return len(doge_words)