From 26a40deffeb77729c650f77f3f2423dae73d5e07 Mon Sep 17 00:00:00 2001 From: Sowmya Yellapragada <56383804+sowmya8900@users.noreply.github.com> Date: Sat, 10 Oct 2020 19:10:17 +0530 Subject: [PATCH 1/3] Create HackerRank-Repeated-String.py --- HackerRank/HackerRank-Repeated-String.py | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 HackerRank/HackerRank-Repeated-String.py diff --git a/HackerRank/HackerRank-Repeated-String.py b/HackerRank/HackerRank-Repeated-String.py new file mode 100644 index 0000000..f06799f --- /dev/null +++ b/HackerRank/HackerRank-Repeated-String.py @@ -0,0 +1,41 @@ +#!/bin/python3 + +import math +import os +import random +import re +import sys + +# Complete the repeatedString function below. +def repeatedString(s, n): + string = '' + if (len(s) == 1 and s == 'a'): + return n + elif (len(s) == 1 and s != 'a'): + return 0 + else: + r = n%len(s) + q = int(n / len(s)) + count = s.count('a') + count = (count*q) + for i in range(r): + string = string + s[i] + for j in string: + if j == 'a': + count = count + 1 + return(count) + + + +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() From 30d8ac5806bf64d9160aee2ff234f24b9acf20f7 Mon Sep 17 00:00:00 2001 From: Sowmya Yellapragada <56383804+sowmya8900@users.noreply.github.com> Date: Sat, 10 Oct 2020 19:11:07 +0530 Subject: [PATCH 2/3] Delete HackerRank-Repeated-String.py --- HackerRank/HackerRank-Repeated-String.py | 41 ------------------------ 1 file changed, 41 deletions(-) delete mode 100644 HackerRank/HackerRank-Repeated-String.py diff --git a/HackerRank/HackerRank-Repeated-String.py b/HackerRank/HackerRank-Repeated-String.py deleted file mode 100644 index f06799f..0000000 --- a/HackerRank/HackerRank-Repeated-String.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/python3 - -import math -import os -import random -import re -import sys - -# Complete the repeatedString function below. -def repeatedString(s, n): - string = '' - if (len(s) == 1 and s == 'a'): - return n - elif (len(s) == 1 and s != 'a'): - return 0 - else: - r = n%len(s) - q = int(n / len(s)) - count = s.count('a') - count = (count*q) - for i in range(r): - string = string + s[i] - for j in string: - if j == 'a': - count = count + 1 - return(count) - - - -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() From 91d1e5295e126e1875c61485ccbae052437a9aaa Mon Sep 17 00:00:00 2001 From: Sowmya Yellapragada <56383804+sowmya8900@users.noreply.github.com> Date: Sat, 10 Oct 2020 19:16:07 +0530 Subject: [PATCH 3/3] Create HackerRank-Repeated-Strings.py --- HackerRank/HackerRank-Repeated-Strings.py | 41 +++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 HackerRank/HackerRank-Repeated-Strings.py diff --git a/HackerRank/HackerRank-Repeated-Strings.py b/HackerRank/HackerRank-Repeated-Strings.py new file mode 100644 index 0000000..f06799f --- /dev/null +++ b/HackerRank/HackerRank-Repeated-Strings.py @@ -0,0 +1,41 @@ +#!/bin/python3 + +import math +import os +import random +import re +import sys + +# Complete the repeatedString function below. +def repeatedString(s, n): + string = '' + if (len(s) == 1 and s == 'a'): + return n + elif (len(s) == 1 and s != 'a'): + return 0 + else: + r = n%len(s) + q = int(n / len(s)) + count = s.count('a') + count = (count*q) + for i in range(r): + string = string + s[i] + for j in string: + if j == 'a': + count = count + 1 + return(count) + + + +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()