2015-12-01 part1 + 2

This commit is contained in:
FrederikBaerentsen 2023-12-04 15:21:31 +01:00
parent 4f0bb12164
commit 9b06a60ac7
4 changed files with 39 additions and 0 deletions

1
2015/day1/input Normal file

File diff suppressed because one or more lines are too long

17
2015/day1/part1.py Normal file
View File

@ -0,0 +1,17 @@
#!/bin/python3
import sys
from pprint import pprint
input_f = sys.argv[1]
result = 0
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)

20
2015/day1/part2.py Normal file
View File

@ -0,0 +1,20 @@
#!/bin/python3
import sys
from pprint import pprint
input_f = sys.argv[1]
result = 0
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
print(result)

1
2015/day1/test Normal file
View File

@ -0,0 +1 @@
))(((((