Matching Two-Character Windows

Imagine comparing two strings with a small window that is always 2 characters wide. Write a function string_match that takes strings a and b and counts the positions where their two-character slices are the same. Only compare positions where both strings have a full two-character slice.

Примеры

Ввод
"xxcaazz", "xxbaaz"
Вывод
3
Ввод
"abc", "abc"
Вывод
2
Ввод
"abc", "axc"
Вывод
0

Нужно реализовать

def string_match(a: str, b: str) -> int:

Теги

strings
PostgreSQLv16

Her vises resultatet af din kode

Visible tests
1
Input
"xxcaazz", "xxbaaz"
Expected3
2
Input
"abc", "abc"
Expected2
3
Input
"abc", "axc"
Expected0
4
Input
"hello", "he"
Expected1
5
Input
"aabbccdd", "abbbxxd"
Expected1
6
Input
"", "x"
Expected0
Focus radio
Paused · SomaFM · Fluid