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)