2015-12-01 part1 + 2
This commit is contained in:
parent
4f0bb12164
commit
9b06a60ac7
1
2015/day1/input
Normal file
1
2015/day1/input
Normal file
File diff suppressed because one or more lines are too long
17
2015/day1/part1.py
Normal file
17
2015/day1/part1.py
Normal 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
20
2015/day1/part2.py
Normal 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
1
2015/day1/test
Normal file
@ -0,0 +1 @@
|
||||
))(((((
|
Loading…
Reference in New Issue
Block a user