diff --git a/soal1.py b/soal1.py new file mode 100644 index 0000000..f93267c --- /dev/null +++ b/soal1.py @@ -0,0 +1,43 @@ +#!/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): + socks={} + count=0 + + for i in ar: + if i not in socks: + socks[i]=1 + continue + socks[i]+=1 + + for i in socks.values(): + count+=i//2 + return count + +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() \ No newline at end of file diff --git a/soal2.py b/soal2.py new file mode 100644 index 0000000..11f09b6 --- /dev/null +++ b/soal2.py @@ -0,0 +1,49 @@ +#!/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): + present=0; + + for i in a: + if i<=0: + present+=1; + + if(present