Matching String Pairs

This exercise shows how to compare two strings by small chunks instead of single characters. Write a function string_match that takes strings a and b and counts the positions where both strings have the same two-character substring at the same index. Only check positions where a full two-character slice exists in both strings.

Примеры

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

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

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

Теги

stringssliding-window
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
"", ""
Expected0
6
Input
"zzaacxx", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Expected1
Focus radio
Paused · SomaFM · Fluid