2015 day 1

This commit is contained in:
2024-12-06 19:01:44 +01:00
parent 67d4a422ed
commit 88913b55f0
3 changed files with 19 additions and 0 deletions

1
2015/day-1/input.txt Normal file

File diff suppressed because one or more lines are too long

8
2015/day-1/part-1.py Normal file
View File

@@ -0,0 +1,8 @@
input = open("input.txt").read()
count = 0
for i, char in enumerate(list(input), start=1):
if char == "(":
count += 1
else:
count -= 1
print(count)

10
2015/day-1/part-2.py Normal file
View File

@@ -0,0 +1,10 @@
input = open("input.txt").read()
count = 0
for i, char in enumerate(list(input), start=1):
if char == "(":
count += 1
else:
if count == 0:
print(i)
break
count -= 1