text and piece. Write piece several times in a row: with k = 3, "ab" becomes "ababab".
Find the largest k for which k glued copies of piece appear in text as a contiguous substring. If piece does not appear in text at all, the answer is 0.text='xyxyxyz', piece='xy' → 3
"xyxyxy" is three copies of "xy" in a row, and it appears in the text. Four copies in a row do not.
text='abcab', piece='ca' → 1
"ca" appears once, but "caca" does not.
text='hello', piece='world' → 0
text='xyxyxyz', piece='xy'
3
Run checks the first 3 tests in your browser. Submit checks all 157 tests on the server, hidden ones included.