CarlosLabs
Hackerrank Challenges - Apple and orange
#!/bin/python3 import math import os import random import re import sys # Complete the countApplesAndOranges function below. def countApplesAndOranges(s, t, a, b, apples, oranges): ix = 0 tgtA = 0 tgtO = 0 appleLoc = 0 orangeLoc = 0 done = False for i in apples: appleLoc = a + apples[ix] if (appleLoc >= s) and (appleLoc <= t): tgtA += 1 ix += 1 ix = 0 for i in oranges: orangeLoc = b + oranges[ix] if (orangeLoc >= s) and (orangeLoc <= t): tgtO += 1 ix += 1 print(tgtA) print(tgtO) return 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)