44 lines
793 B
Python
44 lines
793 B
Python
from collections import namedtuple
|
|
|
|
|
|
Exp = namedtuple("Exp", ["b", "p"])
|
|
|
|
|
|
def gcd(a, b):
|
|
while b != 0:
|
|
a, b = b, a % b
|
|
return a
|
|
|
|
|
|
def compare_exp(a, b):
|
|
g = gcd(a.p, b.p)
|
|
print(g)
|
|
return (Exp(a.b, a.p // g), Exp(b.b, b.p // g))
|
|
|
|
|
|
def read_exps():
|
|
with open("../txt/EulerProblem099.txt", "r") as f:
|
|
return [Exp(int(s[0]), int(s[1]))
|
|
for i, line in enumerate(f.readlines())
|
|
if (s := line.split(","))]
|
|
|
|
|
|
def euler_099():
|
|
pairs = read_exps()
|
|
#a = Exp(2, 350)
|
|
#b = Exp(5, 150)
|
|
|
|
i = 19
|
|
a, b = pairs[i:i + 2]
|
|
print(a, b)
|
|
a, b = compare_exp(a, b)
|
|
print(a, b)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
solution = euler_099()
|
|
print("e099.py: " + str(solution))
|
|
# assert(solution == 0)
|
|
|