Flexible Code Match
Sometimes you need to search for a pattern instead of an exact word, where one character can be anything. Write a function count_code that takes a string s and counts every substring in the form co + any character + e. For example, code, coze, and cope all count.
Примеры
Ввод
"aaacodebbb"Вывод
1Ввод
"codexxcode"Вывод
2Ввод
"cozexxcope"Вывод
2Нужно реализовать
def count_code(s: str) -> int:
Теги
strings
Přihlaste se, abyste viděli historii odevzdání
Přihlásit sePřihlaste se, abyste mohli použít AI mentora
Přihlásit seVisible tests
1
Input
"aaacodebbb"Expected
12
Input
"codexxcode"Expected
23
Input
"cozexxcope"Expected
24
Input
"xxcope"Expected
15
Input
"cope"Expected
16
Input
"code"Expected
1Focus radio
Paused · SomaFM · Fluid