Skip to content

Commit

Permalink
2015: Add day 1 part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
jp7677 committed Dec 15, 2024
1 parent b1bbc6b commit 6a2dd83
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions 2015/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ dependencies = [
disable = [
"missing-module-docstring",
"missing-function-docstring",
"multiple-statements",
]
21 changes: 17 additions & 4 deletions 2015/test_day01.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@


def test_part01():
input_data = read_input("day01-input.txt")
directions = read_input("day01-input.txt")

up = input_data.count(')')
down = input_data.count('(')
floor = abs(up - down)
floor = abs(directions.count(')') - directions.count('('))

assert floor == 138

def test_part02():
directions = read_input("day01-input.txt")

position = 0
floor = 0
for i, f in enumerate(directions):
if f == '(': floor += 1
else: floor -= 1

if floor == -1:
position = i + 1
break

assert position == 1771

0 comments on commit 6a2dd83

Please sign in to comment.