From dac3ef4f1c2b2d44dde35b83211054aeacca8430 Mon Sep 17 00:00:00 2001 From: Saurabh Prakash Giri Date: Wed, 7 Oct 2020 09:16:16 +0530 Subject: [PATCH] Create apple-oranges-hackerank-solution.py Solution of hackerrank problem apples and oranges. --- apple-oranges-hackerank-solution.py | 63 +++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 apple-oranges-hackerank-solution.py diff --git a/apple-oranges-hackerank-solution.py b/apple-oranges-hackerank-solution.py new file mode 100644 index 0000000..1075283 --- /dev/null +++ b/apple-oranges-hackerank-solution.py @@ -0,0 +1,63 @@ +import math +import os +import random +import re +import sys + +# Complete the countApplesAndOranges function below. + +def countApplesAndOranges(s, t, a, b, apples, oranges): + + acount = 0 + + bcount = 0 + + for i in range(len(apples)): + + temp = a+apples[i] + + if(temp in range(s,t+1)): + + acount+=1 + + for i in range(len(oranges)): + + temp = b+oranges[i] + + if(temp in range(s,t+1)): + + bcount+=1 + + print (acount) + + print (bcount) + + + + + +if __name__ == '__main__': + + st = input().split() + + s = int(st[0]) + + t = int(st[1]) + + ab = input().split() + + a = int(ab[0]) + + b = int(ab[1]) + + mn = input().split() + + m = int(mn[0]) + + n = int(mn[1]) + + apples = list(map(int, input().rstrip().split())) + + oranges = list(map(int, input().rstrip().split())) + + CountApplesAndOranges(s, t, a, b, apples, oranges)