Files
advent_of_code/organise_my_repo.py
T
Jake Pullen 803de69aaa updated the organiser to be flexible in years
added 2022 folders
to start going back and doing previous years
2023-12-01 09:26:45 +00:00

51 lines
1.6 KiB
Python

import os
from datetime import datetime
# Define the base directory where you want to create the folders
base_dir = 'advent_of_code'
current_year = datetime.now().year
def create_advent_year(year=current_year):
# Loop over the range 1 to 25 (inclusive)
for i in range(1, 26):
# Construct the folder name
folder_name = f"day_{i}"
# Construct the full path to the folder
folder_path = os.path.join(base_dir,str(year), folder_name)
# Create the folder
os.makedirs(folder_path, exist_ok=True)
# Construct the full path to the placeholder file
input_file_path = os.path.join(folder_path, "input.txt")
puzzle_file_path = os.path.join(folder_path, "puzzle_text.md")
solution_file_path_1 = os.path.join(folder_path, "part 1 solution.py")
solution_file_path_2 = os.path.join(folder_path, "part 2 solution.py")
# Create the placeholder file
with open(input_file_path, "w") as file:
file.write("Paste any inputs into this file.")
# Create the puzzle file
with open(puzzle_file_path, "w") as file:
file.write( f"# Day {i} Puzzle Text.")
# Create the solution file
with open(solution_file_path_1, "w") as file:
file.write(f"""import os
with open(r'{input_file_path}', 'r') as file:
input = file.read()
print(input)
""")
with open(solution_file_path_2, "w") as file:
file.write(f"""import os
with open(r'{input_file_path}', 'r') as file:
input = file.read()
print(input)
""")
create_advent_year(2022)