2024-Advent-of-Code/AOC_Helpers/file_utils.py
2024-12-03 11:51:03 -07:00

23 lines
No EOL
652 B
Python

import ast
def get_input_file(data_path: str, day: int) -> str:
"""
Get the path to the input file for the given problem.
:param data_path: Path to the data directory.
:param problem: Problem number.
:return: Path to the input file.
"""
return f"{data_path}/input_{day:02d}.txt"
def list_from_file(file_path):
"""
Read the file containing the brick data and parse it into a Python list.
:param file_path: Path to the file containing the brick data.
:return: Parsed list of bricks.
"""
with open(file_path, 'r') as file:
data = file.read()
ls = ast.literal_eval(data)
return ls