コード例 #1
0
ファイル: problem_003.py プロジェクト: gante/project_euler
def get_solution():
    """ Solves the problem and returns the answer.

    NOTE: At the time of writing, JAX does not enable 64 bit operations by default, required to
    solve this problem. Check the configuration at the top of this script.
    """
    max_prime = np.sqrt(NUMBER).astype(int)  # No point looking after this one
    primes_list = jnp.asarray(get_all_primes(max_prime=max_prime),
                              dtype=jnp.int32)
    return compute_solution(NUMBER, primes_list)
コード例 #2
0
ファイル: problem_012.py プロジェクト: gante/project_euler
def get_solution():
    """ Solves the problem and returns the answer.
    """
    primes_list = get_all_primes(max_prime=MAX_PRIME)
    triangle_sequence = np.asarray(triangle_up_to(value=MAX_INT), dtype=int)
    n_combinations = compute_solution(
        primes_list=jnp.asarray(primes_list, dtype=jnp.int32),
        triangle_sequence=jnp.asarray(triangle_sequence,
                                      dtype=jnp.int32)).astype(int)
    # Easier to do masks outside jax :D
    return min(triangle_sequence[n_combinations > 500])
コード例 #3
0
def get_solution():
    """ Solves the problem and returns the answer.
    """
    return np.sum(get_all_primes(max_prime=2000000))
コード例 #4
0
ファイル: problem_005.py プロジェクト: gante/project_euler
def get_solution():
    """ Solves the problem and returns the answer.
    """
    primes_list = jnp.asarray(get_all_primes(max_prime=MAX_NUMBER),
                              dtype=jnp.int32)
    return compute_solution(MAX_NUMBER, primes_list)
コード例 #5
0
ファイル: problem_007.py プロジェクト: gante/project_euler
def get_solution():
    """ Solves the problem and returns the answer.
    """
    return get_all_primes(n_primes=10001)[-1]