Kozlinskii/DIVSTR — различия между версиями

Материал из DISCOPAL
Перейти к: навигация, поиск
(Новая страница: «<code-python> def pseudo_divisible(s, t): i = 0 j = 0 ans = 0 while i < len(s): if s[i] == t[j]: i += 1 j += 1…»)
 
(нет различий)

Текущая версия на 20:46, 31 октября 2020

def pseudo_divisible(s, t):
    i = 0
    j = 0
    ans = 0
    while i < len(s):
        if s[i] == t[j]:
            i += 1
            j += 1
            if j >= len(t):
                j = 0
        else:
            i += 1
            ans += 1
    return ans + j
 
n = int(input())
for _ in range(n):
    s = input()
    t = input()
    print(pseudo_divisible(s, t))