Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/python3
- import math
- import os
- import random
- import re
- import sys
- # Complete the repeatedString function below.
- def repeatedString(s, n):
- count = 0
- for i in s:
- if i == 'a':
- count = count + 1
- length = len(s);
- num_repeat = math.floor(n/length);
- total_count_a = num_repeat * count;
- #handle remainder
- remaining_letters = n - (num_repeat * length)
- for i in range(0, remaining_letters):
- if s[i] == 'a':
- total_count_a += 1
- return total_count_a
- if __name__ == '__main__':
- fptr = open(os.environ['OUTPUT_PATH'], 'w')
- s = input()
- n = int(input())
- result = repeatedString(s, n)
- fptr.write(str(result) + '\n')
- fptr.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement