Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions soal-1.py
Original file line number Diff line number Diff line change
@@ -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()
50 changes: 50 additions & 0 deletions soal-2.py
Original file line number Diff line number Diff line change
@@ -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()
60 changes: 60 additions & 0 deletions soal-3.py
Original file line number Diff line number Diff line change
@@ -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()
45 changes: 45 additions & 0 deletions soal-4.py
Original file line number Diff line number Diff line change
@@ -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()