AdventOfCode2015/day1.py
marcus@weifer.de 17687ac959 change paths
2022-12-14 10:38:57 +01:00

36 lines
605 B
Python

file = "inputs/day1.txt"
lines = []
with open(file) as input:
lines = input.readline()
def part_one(lines):
up = 0
down = 0
for char in lines:
if(char == "("):
up +=1
else:
down += 1
print(f"Part 1: {up - down}")
def part_two(lines):
up = 0
down = 0
counter = 0
for char in lines:
if((up - down) == -1):
print(f"Part 2: {counter}")
break
else:
counter += 1
if (char == "("):
up += 1
else:
down += 1
part_one(lines)
part_two(lines)