-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
31 lines (27 loc) · 964 Bytes
/
Copy pathutils.py
File metadata and controls
31 lines (27 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
def filereader(day,type):
if type:
with open(f'Input - Day {day}.txt') as f:
return f.read().strip().split("\n")
else:
with open(f'Test - Day {day}.txt') as f:
return f.read().strip().split("\n")
def daysetup(day):
# create new directory
os.mkdir(f"C:/Users/Pierre/Documents/.Programming/python/AdventOfCode2022/2022/Day{day}")
# create both python files with filereader at the beginning
lines = f"\
from utils import filereader\n\
\n\
input = filereader({day},False)\
"
with open(f"2022/Day{day}/Day{day}-Part1.py","x") as f:
f.write(lines)
with open(f"2022/Day{day}/Day{day}-Part2.py", "x") as f:
f.write(lines)
# create both input files
open(f"2022/Day{day}/Input - Day {day}.txt", "x")
open(f"2022/Day{day}/Test - Day {day}.txt", "x")
if __name__ == "__main__":
day = input("Number of Day: ")
daysetup(day)