Count in a Repeated String
Imagine repeating a string again and again until it becomes a very long tape of characters. The function repeated_string receives a string s and a number n. Look only at the first n characters of this repeated tape and count how many times the letter a appears.
Примеры
Ввод
"aba", 10Вывод
7Ввод
"a", 1000000Вывод
1000000Ввод
"abc", 3Вывод
1Нужно реализовать
def repeated_string(s: str, n: int) -> int:
Теги
stringsmath
Idħol biex tara l-istorja tas-sottomissjonijiet
IdħolIdħol biex tuża l-Mentor tal-AI
IdħolVisible tests
1
Input
"aba", 10Expected
72
Input
"a", 1000000Expected
10000003
Input
"abc", 3Expected
14
Input
"bb", 100Expected
05
Input
"aaa", 7Expected
76
Input
"a", 999999Expected
999999Focus radio
Paused · SomaFM · Fluid