From be9ea845e60fb176eb47d1cf67f6c671da24ccfd Mon Sep 17 00:00:00 2001 From: marwanjuna Date: Tue, 8 Jun 2021 11:00:55 +0700 Subject: [PATCH 1/5] soal-1 done --- soal-1.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 soal-1.py diff --git a/soal-1.py b/soal-1.py new file mode 100644 index 0000000..14d00b6 --- /dev/null +++ b/soal-1.py @@ -0,0 +1,45 @@ +#!/bin/python3 + +import math +import os +import random +import re +import sys + +# +# Complete the 'sockMerchant' function below. +# +# The function is expected to return an INTEGER. +# The function accepts following parameters: +# 1. INTEGER n +# 2. INTEGER_ARRAY ar +# + + +def sockMerchant(n, ar): + # Write your code here + pair_counter = 0 + check = [] + + for i in range(n): + if not ar[i] in check: + check.append(ar[i]) + else: + check.remove(ar[i]) + pair_counter += 1 + print(check) + return pair_counter + + +if __name__ == '__main__': + fptr = open(os.environ['OUTPUT_PATH'], 'w') + + n = int(input().strip()) + + ar = list(map(int, input().rstrip().split())) + + result = sockMerchant(n, ar) + + fptr.write(str(result) + '\n') + + fptr.close() From 0778719ca48590f65f8e0f31007ffc24ad1fbd76 Mon Sep 17 00:00:00 2001 From: marwanjuna Date: Tue, 8 Jun 2021 11:20:01 +0700 Subject: [PATCH 2/5] soal-2 done --- soal-2.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 soal-2.py diff --git a/soal-2.py b/soal-2.py new file mode 100644 index 0000000..f153ebc --- /dev/null +++ b/soal-2.py @@ -0,0 +1,50 @@ +#!/bin/python3 + +import math +import os +import random +import re +import sys + +# +# Complete the 'angryProfessor' function below. +# +# The function is expected to return a STRING. +# The function accepts following parameters: +# 1. INTEGER k +# 2. INTEGER_ARRAY a +# + +def angryProfessor(k, a): + # Write your code here + arrived_on = 0 + late = 0 + for i in a: + if i <= 1: + arrived_on += 1 + else: + late += 1 + if arrived_on >= k: + return "NO" + else: + return "YES" + +if __name__ == '__main__': + fptr = open(os.environ['OUTPUT_PATH'], 'w') + + t = int(input().strip()) + + for t_itr in range(t): + first_multiple_input = input().rstrip().split() + + n = int(first_multiple_input[0]) + + k = int(first_multiple_input[1]) + + a = list(map(int, input().rstrip().split())) + + result = angryProfessor(k, a) + + fptr.write(result + '\n') + + fptr.close() From 0a198f0d2fbf26dfeb3507b279253ee0bd056765 Mon Sep 17 00:00:00 2001 From: marwanjuna Date: Tue, 8 Jun 2021 12:08:06 +0700 Subject: [PATCH 3/5] soal-3 done --- soal-3.py | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 soal-3.py diff --git a/soal-3.py b/soal-3.py new file mode 100644 index 0000000..9681627 --- /dev/null +++ b/soal-3.py @@ -0,0 +1,60 @@ +#!/bin/python3 + +import math +import os +import random +import re +import sys + +# +# Complete the 'migratoryBirds' function below. +# +# The function is expected to return an INTEGER. +# The function accepts INTEGER_ARRAY arr as parameter. +# + + +def migratoryBirds(arr): + # Write your code here + type = { + 1: 0, + 2: 0, + 3: 0, + 4: 0, + 5: 0 + } + + for i in arr: + if i == 1: + type[1] += 1 + elif i == 2: + type[2] += 1 + elif i == 3: + type[3] += 1 + elif i == 4: + type[4] += 1 + else: + type[5] += 1 + + max = 0 + answer = 0 + for key in type: + if max < type[key]: + max = type[key] + answer = key + + return answer + + +if __name__ == '__main__': + fptr = open(os.environ['OUTPUT_PATH'], 'w') + + arr_count = int(input().strip()) + + arr = list(map(int, input().rstrip().split())) + + result = migratoryBirds(arr) + + fptr.write(str(result) + '\n') + + fptr.close() From df32b6612edc3058b919d8e108b0170b75763536 Mon Sep 17 00:00:00 2001 From: marwanjuna Date: Tue, 8 Jun 2021 13:16:42 +0700 Subject: [PATCH 4/5] soal-4 done --- soal-4.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 soal-4.py diff --git a/soal-4.py b/soal-4.py new file mode 100644 index 0000000..e69de29 From 988f8002382c13c4230063731a98a54e6235f486 Mon Sep 17 00:00:00 2001 From: marwanjuna Date: Tue, 8 Jun 2021 13:18:46 +0700 Subject: [PATCH 5/5] soal-4 done --- soal-4.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/soal-4.py b/soal-4.py index e69de29..e483bf0 100644 --- a/soal-4.py +++ b/soal-4.py @@ -0,0 +1,45 @@ +#!/bin/python3 + +import math +import os +import random +import re +import sys + +# +# Complete the 'repeatedString' function below. +# +# The function is expected to return a LONG_INTEGER. +# The function accepts following parameters: +# 1. STRING s +# 2. LONG_INTEGER n +# + + +def repeatedString(s, n): + # Write your code here + x = int(n / len(s)) + mod = n % len(s) + # print(x, mod) + + front_str = s[:mod] + # print(front_str) + back_str = s[mod:] + # print(back_str) + total_1 = front_str.count("a")*(x+1) + total_2 = back_str.count("a")*x + return total_1 + total_2 + + +if __name__ == '__main__': + fptr = open(os.environ['OUTPUT_PATH'], 'w') + + s = input() + + n = int(input().strip()) + + result = repeatedString(s, n) + + fptr.write(str(result) + '\n') + + fptr.close()