Fruit on the House
Sam’s house covers the number line segment from s to t, inclusive. The apple tree is at point a, the orange tree is at point b, and the lists apples and oranges contain each fruit’s offset from its tree. Calculate where each fruit lands and return [apple_count, orange_count]: how many apples and oranges land on the house.
Примеры
Ввод
7, 11, 5, 15, [-2, 2, 1], [5, -6]Вывод
[1, 1]Ввод
7, 10, 4, 12, [2, 3, -4], [3, -2, -4]Вывод
[1, 2]Ввод
1, 5, 0, 6, [1, 3, 5], [-1, -3, -5]Вывод
[3, 3]Нужно реализовать
def apple_and_orange(s: int, t: int, a: int, b: int, apples: list[int], oranges: list[int]) -> list[int]:
Теги
arraymath
Log ind for at se indsendelseshistorik
Log indLog ind for at bruge AI-mentor
Log indVisible tests
1
Input
7, 11, 5, 15, [-2,2,1], [5,-6]Expected
[1,1]2
Input
7, 10, 4, 12, [2,3,-4], [3,-2,-4]Expected
[1,2]3
Input
1, 5, 0, 6, [1,3,5], [-1,-3,-5]Expected
[3,3]4
Input
10, 20, 5, 25, [1,2,3], [1,2,3]Expected
[0,0]5
Input
2, 3, 1, 5, [1], [-2]Expected
[1,1]6
Input
10, 40, 5, 25, [1,2,3], [1,2,3]Expected
[0,3]Focus radio
Paused · SomaFM · Fluid