Given two strings a
and b
, count how many times b
occurs as a substring in a
, but only when it overlaps with another instance of b
.
(This means that 1
will never be a valid output, because in order for the substring to be strictly overlapping, there must be at least one other instance for it to overlap with.)
Test cases
input a input b output
trololololol trol 0
trololololol ol 0
trololololol lol 4
trololololol LOL 0
HAAAAHAAAAA A 0
HAAAAHAAAAA AA 7
Teeheeee ee 3
123123123123123123 12312312 4
(empty string) whatever 0
b
will never be an empty string.
Rules
- Matching must be case-sensitive
- You may use any sensible IO format
- Standard loopholes apply
- This is code-golf, so the shortest code in bytes wins.
b
is empty? \$\endgroup\$b
isn't empty") \$\endgroup\$a
begins with a single occurrence ofb
and later contains overlappedb
s. eeheeee \$\endgroup\$