Skip to content

tiredterry

bradendubois edited this page Nov 8, 2021 · 9 revisions

Tired Terry

ID: tiredterry

Difficulty: 3.2

CPU Time: 1 second

Memory: 1024 MB

Solution

For this one, one needs to sum the tallies of the characters in the slice of i to p for "W" and "Z", and always check if the tally for "Z" is strictly less than d. One needs to go faster than to actually recount at every possible interval (which loops around after the end back to the start of the sleep pattern, which can be handled with some modulo division into the string), since there is only one new character at the end, and one character being removed at the start. For a speedup, one can count every character for the first iteration, and then only count the new character being inserted, and remove the character at the start of the interval to keep track more efficiently.

Clone this wiki locally