-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create apple-oranges-hackerank-solution.py
Solution of hackerrank problem apples and oranges.
- Loading branch information
1 parent
332df85
commit dac3ef4
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |