Fix: Ensure all skills are tracked as files, not submodules
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
def how_many_times(string: str, substring: str) -> int:
|
||||
""" Find how many times a given substring can be found in the original string. Count overlaping cases.
|
||||
>>> how_many_times('', 'a')
|
||||
0
|
||||
>>> how_many_times('aaa', 'a')
|
||||
3
|
||||
>>> how_many_times('aaaa', 'aa')
|
||||
3
|
||||
"""
|
||||
if not substring or not string:
|
||||
return 0
|
||||
|
||||
count = 0
|
||||
start = 0
|
||||
|
||||
while True:
|
||||
pos = string.find(substring, start)
|
||||
if pos == -1:
|
||||
break
|
||||
count += 1
|
||||
start = pos + 1
|
||||
|
||||
return count
|
||||
Reference in New Issue
Block a user