AdventOfCode2015/day1.py

36 lines
598 B
Python
Raw Normal View History

2022-12-14 10:37:36 +01:00
file = "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)