John Lekberg


JUNTO Practice - "Project Euler Problem 99"

Discussed on 2019-01-21.

Project Euler Problem 99


Solution - Daniel

#!/usr/bin/env python

"""Find greatest base-exponent pair (Euler Problem 99)."""

_author_ = "Daniel Bassett"

import math
from math import log10

"""Sought guidance. See https://zach.se/project-euler-solutions/99/"""

greatest = [0, 0]

for i, line in enumerate(open("p099_base_exp.txt", "r")):
    y, x = list(map(int, line.split(",")))
    if x * log10(y) > greatest[0]:
        greatest = [x * log10(y), i + 1]
print(greatest[1])

Solution - John

#!/usr/bin/env python3

"""Solution to Project Euler Problem 99."""

import numpy as np

__author__ = "John Lekberg"

with open("p099_base_exp.txt", "r") as infile:
    pairs = np.loadtxt(infile, delimiter=",")
    log_values = np.log(pairs[:, 0]) * pairs[:, 1]
    print(1 + np.argmax(log_values))

Solution - Oscar

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jan  3 11:33:37 2019

@author: oscarmartinez
"""

# %% General implementation
import numpy as np

arr = np.loadtxt(
    "p099_base_exp.txt", dtype=np.float64, delimiter=","
)
print(np.argmax(np.log2(arr[:, 0]) * arr[:, 1]) + 1)