Say "Hello, World!" With Python

  • + 0 comments

    Simple solution: Find how many a's in s and multiply it by how many times s repeats so that s. Find how many a's in the leftover of the division and add it.

    def repeatedString(s, n):
        return len(re.sub(r'[^a]',"",s))*(n//len(s)) + len(re.sub(r'[^a]',"",s[:n%len(s)]))