word. Every second two things must happen: the first step characters drop off the left end, and you append exactly step lowercase letters of your choice on the right. They do not have to be the letters that dropped off.
Find the smallest positive number of seconds after which the display can show the original word again.word='abcabcab', step=3 → 1
After one second the part still on the tape is "abcab", which is exactly how the word begins. Appending "cab" brings back "abcabcab".
word='banana', step=2 → 3
After the first second "nana" remains, after the second "na"; neither is how "banana" begins. By the third second nothing of the original is left, so the whole word can be written anew.
word='abab', step=1 → 2
After one second "bab" is left, which does not fit. After two, "ab" is left: it starts "abab", so we append "ab".
word.length ≤ 10⁶step ≤ word.lengthword consists of lowercase English letters onlyword='abcabcab', step=3
1
Run checks the first 3 tests in your browser. Submit checks all 111 tests on the server, hidden ones included.