• + 1 comment

    By the way my first attempt timed out on two test cases (whereas iampetermitsel's solution works). Can somebody help me, how is my solution different from his?

        min_b = b[0]
    max_a = a[-1]
    
    common_multiples_a = []
    elem = max_a
    while elem <= min_b:
        if all(elem % item == 0 for item in a):
            common_multiples_a.append(elem)
            elem += max_a
    
    count = 0
    for elem in common_multiples_a:
        if all(item % elem == 0 for item in b):
            count +=1
    
            return count