Esempio n. 1
0
def test_subarray_sum():
    """Tests subarray_sum function """

    assert [20, 3, 10] == subarray_sum([1, 4, 20, 3, 10, 5], 33)
    assert [4, 0, 0, 3] == subarray_sum([1, 4, 0, 0, 3, 10, 5], 7)
    assert [] == subarray_sum([1, 4], 0)
    assert [2] == subarray_sum([2], 2)
    assert [] == subarray_sum([2], 3)
def problem_50():
    """ Attempt to solve the problem... """

    primes = list(seive_generator(1000000))
    best = (0, 0)
    for prime in primes:
        ans = subarray_sum(primes[:int(prime ** 0.5)], prime)
        if len(ans) > best[1]:
            best = (prime, len(ans))
    return best[0]