advent-of-code/2015-python/solutions/day_01.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

26 lines
552 B
Python

from solutions import BaseSolution
class Solution(BaseSolution):
input_file = "01.txt"
def __str__(self):
return "Day 1: Not Quite Lisp"
def solve(self, pi):
return sum([-1 if c == ")" else 1 for c in pi])
def solve_again(self, pi):
f = 1
for i, v in enumerate(pi):
f += -1 if v == ")" else 1
if f == -1:
return i
def parse_input(self, data):
return data.strip()
if __name__ == "__main__":
solution = Solution()
solution.show_results()