advent-of-code/2015-python/aoc.py
Anders Englöf Ytterström 28af87c00b Add the initial 2015 days in Python
These are already done in Elixir, so this is
just done for the flex.

Also, coming from Day 16-18 from 2023 calendar,
it is safe to say 2015 puzzles are easier and more
manageable.
2023-12-19 23:55:47 +01:00

82 lines
1.7 KiB
Python

import sys
year = 2015
try:
_, day_no, name = sys.argv
except ValueError:
day_no = None
name = None
print(
f"\nAdvent of Code {year}" "\n###################" "\n\nby Anders Englöf Ytterström"
)
if day_no and name:
print(f"\n- creating solutions/day_{day_no.zfill(2)}.py")
with open("solutions/day_{}.py".format(day_no.zfill(2)), "w") as s:
s.write(
"""
from solutions import BaseSolution
class Solution(BaseSolution):
input_file = "{day_no}.txt"
def __str__(self):
return "Day {day}: {name}"
def solve(self, pi):
return pi
def solve_again(self, pi):
return pi
def parse_input(self, data):
return data.strip()
if __name__ == "__main__":
solution = Solution()
# solution.show_results()
dummy = \"\"\"
replace me
\"\"\".strip()
solution.solve(dummy)
# solution.solve_again(dummy)
""".strip().format(
day=day_no, day_no=day_no.zfill(2), name=name
)
+ "\n"
)
print(
f"""
Done! start coding.
Puzzle link:
https://adventofcode.com/{year}/day/{day_no}
Puzzle input (copy and paste to inputs/{day_no.zfill(2)}.txt):
https://adventofcode.com/{year}/day/{day_no}/input
"""
)
exit(0)
stars = 0
for i in [str(n).zfill(2) for n in range(1, 26)]:
try:
solution = __import__(
"solutions.day_{}".format(i), globals(), locals(), ["Solution"], 0
).Solution()
solution.show_results()
stars += 2
except IOError:
pass
except ImportError:
pass
print(f"\nStars: {stars}")
print("".join("*" if n < stars else "" for n in range(50)))
print("")