-
Notifications
You must be signed in to change notification settings - Fork 433
Expand file tree
/
Copy path002. Apple and Orange.py
More file actions
29 lines (23 loc) · 894 Bytes
/
002. Apple and Orange.py
File metadata and controls
29 lines (23 loc) · 894 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
28
29
# Problem: https://www.hackerrank.com/challenges/apple-and-orange/problem
# Score: 10
# Read input values
s, t = map(int, input().split()) # House start and end point
a, b = map(int, input().split()) # Apple tree and orange tree position
m, n = map(int, input().split()) # Number of apples and oranges
# Distances apples fell from the apple tree
apples = list(map(int, input().split()))
# Distances oranges fell from the orange tree
oranges = list(map(int, input().split()))
# Count how many apples fell on the house
apple_count = 0
for d in apples:
if s <= a + d <= t: # Final position of apple is within house range
apple_count += 1
# Count how many oranges fell on the house
orange_count = 0
for d in oranges:
if s <= b + d <= t: # Final position of orange is within house range
orange_count += 1
# Print the results
print(apple_count)
print(orange_count)