day 18 done

This commit is contained in:
Jake Pullen
2023-12-18 08:09:53 +00:00
parent f7f26a6750
commit b4b7a5ae9e
3 changed files with 132 additions and 4 deletions
+9 -4
View File
@@ -86,11 +86,16 @@ def create_solution_file(year, day, part):
os.makedirs(folder, exist_ok=True)
solution_file = os.path.join(folder, f"part {part} solution.py")
input_file_path = os.path.join(folder, "input.txt")
with open(solution_file, "w") as file:
file.write(f"""with open(r'{input_file_path}', 'r') as file:
# Check if the solution file already exists
if not os.path.exists(solution_file):
with open(solution_file, "w") as file:
file.write(f"""with open(r'{input_file_path}', 'r') as file:
input = file.read()
""")
print(f"Created {solution_file}")
print(f"Created {solution_file}")
else:
print(f"{solution_file} already exists. No action taken.")
# Usage example
@@ -125,4 +130,4 @@ def populate_data(year = current_year, day=current_day):
else:
print("Something went wrong. Check the puzzle text.")
populate_data(2023,1)
populate_data(2023,17)