Skip to content

Commit

Permalink
Fix bug when creating puzzle for a new year
Browse files Browse the repository at this point in the history
  • Loading branch information
Spacerulerwill committed Jan 7, 2025
1 parent 7c0998f commit 786c78a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .replit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
modules = ["python-3.11"]
6 changes: 3 additions & 3 deletions aoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ def puzzle(input: str) -> Any: ...

def init_puzzle(year: int, day: int, part: int, force: bool) -> None:
folder_path = os.path.join(PUZZLE_LOCATION, f"Y{year}", f"D{day}")
puzzle_name = os.path.join(folder_path, f"p{part}.py")
os.makedirs(folder_path, exist_ok=True)
# each year is a separate module
with suppress(FileExistsError):
with open(os.path.join(PUZZLE_LOCATION, f"Y{year}", "__init__.py"), "w"):
with open(os.path.join(PUZZLE_LOCATION, f"Y{year}", "__init__.py"), "w+"):
pass
puzzle_name = os.path.join(folder_path, f"p{part}.py")
os.makedirs(folder_path, exist_ok=True)

# Create or overwrite the puzzle file
try:
Expand Down

0 comments on commit 786c78a

Please sign in to comment.