-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathapple-and-orange.py
More file actions
27 lines (23 loc) · 833 Bytes
/
Copy pathapple-and-orange.py
File metadata and controls
27 lines (23 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// https://www.hackerrank.com/challenges/apple-and-orange/problem
def countApplesAndOranges(s, t, a, b, apples, oranges):
# s-t hourse range limitis
# a: tree position
#b : orange position (on the right side of the house)
number_of_apples = 0
number_of_oranges = 0
for single_apple in apples:
if(single_apple < 0):
continue
else:
apple_position = a +single_apple
if(apple_position >= s and apple_position <= t):
number_of_apples+=1
for single_orange in oranges:
if(single_orange > 0):
continue
else:
orange_position = b + single_orange
if(orange_position >= s and orange_position <= t):
number_of_oranges+=1
print(number_of_apples)
print(number_of_oranges)