In [55]:
# https://www.hackerrank.com/challenges/between-two-sets/problem

In [56]:
def gcd(x, y):
    while(y):
        x, y = y, x % y
    return x

def lcm(x, y):
    return int(x * y / gcd(x, y))

In [57]:
a = list(map(int, "100 99 98 97 96 95 94 93 92 91".rstrip().split()))
b = list(map(int, "1 2 3 4 5 6 7 8 9 10".rstrip().split()))

In [58]:
def getTotalX(a, b):
    lcm_a = a[0]
    for number in a[1:]:
        lcm_a = lcm(lcm_a, number)
    gcd_b = b[0]
    for number in b[1:]:
        gcd_b = gcd(gcd_b, number)
    if gcd_b % lcm_a == 0:
        return len([number for number in range(lcm_a, gcd_b + 1, lcm_a) if gcd_b % number == 0])
    return 0

In [59]:
getTotalX(a, b)


Out[59]:
0

In [60]:
# https://www.hackerrank.com/challenges/breaking-best-and-worst-records/problem

In [70]:
scores = list(map(int, "10 5 20 20 4 5 2 25 1".rstrip().split()))

In [71]:
scores


Out[71]:
[10, 5, 20, 20, 4, 5, 2, 25, 1]

In [72]:
def breakingRecords(scores):
    nlow = 0
    nhigh = 0
    low = scores[0]
    high = scores[0]
    for score in scores[1:]:
        if score < low:
            nlow += 1
            low = score
        if score > high:
            nhigh += 1
            high = score
    return "{} {}".format(nhigh, nlow)

In [73]:
breakingRecords(scores)


Out[73]:
'2 4'

In [75]:
# https://www.hackerrank.com/challenges/breaking-best-and-worst-records/problem

In [93]:
# d: sum
# m: number of integers
d, m = 4, 1
s = list(map(int, "4".rstrip().split()))

In [94]:
s


Out[94]:
[4]

In [100]:
ret = 0
for i in range(len(s) - m + 1):
    if sum(s[i: i + m]) == d:
        ret += 1

In [101]:
ret


Out[101]:
1

In [104]:
# https://www.hackerrank.com/challenges/breaking-best-and-worst-records/problem

In [ ]: