Skip to content

Commit b5803e8

Browse files
committed
Split up day 1 solutions
1 parent d5317b1 commit b5803e8

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed

Day1/nql.py

-31
This file was deleted.

Day1/part1.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def part1( fname ):
2+
inputfile = open(fname)
3+
line = inputfile.readline()
4+
inputfile.close()
5+
floor = 0
6+
for x in line:
7+
if x == '(':
8+
floor += 1
9+
elif x == ')':
10+
floor -= 1
11+
return floor
12+
13+
print(part1("input"))

Day1/part2.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def part2( fname ):
2+
inputfile = open(fname)
3+
line = inputfile.readline()
4+
inputfile.close()
5+
floor = 0
6+
pos = 0
7+
for x in line:
8+
if x == '(':
9+
floor += 1
10+
elif x == ')':
11+
floor -= 1
12+
pos += 1
13+
if floor < 0:
14+
break
15+
return pos
16+
17+
print(part2("input"))

0 commit comments

Comments
 (0)