Corrected path for input file
This commit is contained in:
parent
ed8107e84c
commit
d5fdd2a8fd
@ -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:]
|
||||
|
@ -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
|
||||
@ -30,4 +31,4 @@ def compute():
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
print(f"Result for Problem 13: {compute()}")
|
||||
print(f"Result for Problem 13: {compute()}")
|
||||
|
@ -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):
|
||||
@ -39,4 +40,4 @@ def compute():
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
print(f"Result for Problem 22: {compute()}")
|
||||
print(f"Result for Problem 22: {compute()}")
|
||||
|
@ -10,6 +10,7 @@ https://projecteuler.net/problem=42
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from utils import timeit
|
||||
|
||||
|
||||
@ -31,15 +32,15 @@ def compute():
|
||||
"""
|
||||
|
||||
def triangle_number(num):
|
||||
return int(0.5*num*(num+1))
|
||||
return int(0.5 * num * (num + 1))
|
||||
|
||||
def word_to_value(word):
|
||||
return sum(ord(letter)-64 for letter in word)
|
||||
|
||||
return sum(ord(letter) - 64 for letter in word)
|
||||
|
||||
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()}")
|
||||
print(f"Result for Problem 42: {compute()}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user