advent-of-code/2021-python/solutions/__init__.py
Anders Ytterström d5a29d41e2 🔧 Setup Advent of Code 2021
This year: Elixir! And maybe python.
2021-10-22 17:17:55 +02:00

32 lines
885 B
Python

class BaseSolution:
input_file = None
trim_input = True
def read_input(self, filename):
filepath = "./inputs/{}".format(filename)
with open(filepath, "r") as f:
data = f.read()
if self.trim_input:
return data.strip()
return data
def show_results(self):
data = self.read_input(self.input_file)
puzzle_input = self.parse_input(data)
print(
"\n\n{}\n{}\n\nPart 1: {}\nPart 2: {}".format(
str(self),
"-" * len(str(self)),
self.solve(puzzle_input),
self.solve_again(puzzle_input),
)
)
def solve(self, puzzle_input):
raise NotImplemented
def solve_again(self, puzzle_input):
raise NotImplemented
def parse_input(self, data):
raise NotImplemented