Corrected path for input file

This commit is contained in:
David Doblas Jiménez 2022-08-18 10:46:57 +02:00
parent ed8107e84c
commit d5fdd2a8fd
4 changed files with 17 additions and 12 deletions

View File

@ -10,6 +10,7 @@ https://projecteuler.net/problem=54
"""
from pathlib import Path
from utils import timeit
@ -115,7 +116,7 @@ def compute():
replace_map = {"T": 10, "J": 11, "Q": 12, "K": 13, "A": 14}
score = [0, 0]
file = Path("/datos/Scripts/Gitea/Project_Euler/src/files/Problem54.txt")
file = Path("../files/Problem54.txt")
for line in open(file, "r").read().splitlines():
line = replace_values_in_string(line, replace_map).split()
hands = line[:5], line[5:]

View File

@ -10,6 +10,7 @@ https://projecteuler.net/problem=13
"""
from pathlib import Path
from utils import timeit
@ -19,7 +20,7 @@ def compute():
Work out the first ten digits of the sum of the following one-hundred
50-digit numbers.
"""
file = Path("/datos/Scripts/Gitea/Project_Euler/src/files/Problem13.txt")
file = Path("../files/Problem13.txt")
with open(file, "r") as f:
num = f.readlines()
result = 0

View File

@ -10,6 +10,7 @@ https://projecteuler.net/problem=22
"""
from pathlib import Path
from utils import timeit
@ -27,9 +28,9 @@ def compute():
What is the total of all the name scores in the file?
"""
file = Path("/datos/Scripts/Gitea/Project_Euler/src/files/Problem22.txt")
with open(file, 'r') as f:
names = sorted(f.read().replace('"', '').split(','))
file = Path("../files/Problem22.txt")
with open(file, "r") as f:
names = sorted(f.read().replace('"', "").split(","))
result = 0
for idx, name in enumerate(names, 1):

View File

@ -10,6 +10,7 @@ https://projecteuler.net/problem=42
"""
from pathlib import Path
from utils import timeit
@ -39,7 +40,7 @@ def compute():
triangular_numbers = [triangle_number(n) for n in range(27)]
ans = 0
file = Path("/datos/Scripts/Gitea/Project_Euler/src/files/Problem42.txt")
file = Path("../files/Problem42.txt")
with open(file, "r") as f:
words = f.readline().strip('"').split('","')
for word in words:
@ -48,6 +49,7 @@ def compute():
return ans
if __name__ == "__main__":
print(f"Result for Problem 42: {compute()}")