AdventOfCode/2015/01/solution.py

46 lines
1.1 KiB
Python

#!/bin/python3
import sys,re
from pprint import pprint
sys.path.insert(0, '../../')
from fred import list2int
input_f = 'input'
part = 2
#########################################
# #
# Part 1 #
# #
#########################################
result = 0
if part == 1:
with open(input_f) as file:
for line in file:
for idx,i in enumerate(line):
if i == '(':
result += 1
if i == ')':
result -= 1
print(result)
#########################################
# #
# Part 2 #
# #
#########################################
result = 0
if part == 2:
with open(input_f) as file:
for line in file:
for idx,i in enumerate(line):
if i == '(':
result += 1
if i == ')':
result -= 1
if result == -1:
print(idx+1)
break