• + 0 comments

    Python

    def repeatedString(string: str, substring_size: int)-> int:
        # This code can be simplified, but maintainability wins
        # How many characters are in the repeating string
        size: int = len(string)
        # If the number of times the string repeats has remainder, account it
        last_position: int = substring_size % size
        # Number of times the string repeats entirely
        full_repeats: int = substring_size // size
        
        return string.count('a') * full_repeats + string[0: last_position].count('a')