Compare commits
6 Commits
7cd663278e
...
536070e45c
| Author | SHA1 | Date | |
|---|---|---|---|
| 536070e45c | |||
| 7a88149ed9 | |||
| f1b41dc9c7 | |||
| 66007c5389 | |||
| e8e76885ae | |||
| 7a657f8585 |
1
2015/01/python/.python-version
Normal file
1
2015/01/python/.python-version
Normal file
@@ -0,0 +1 @@
|
||||
3.13
|
||||
34
2015/01/python/main.py
Normal file
34
2015/01/python/main.py
Normal file
@@ -0,0 +1,34 @@
|
||||
def main():
|
||||
input = read_file("../input.txt")
|
||||
data = list(input)
|
||||
print(part1(data))
|
||||
print(part2(data))
|
||||
|
||||
def part1(data: list[str]) -> int:
|
||||
floor_level = 0
|
||||
for c in data:
|
||||
if c == "(":
|
||||
floor_level += 1
|
||||
else:
|
||||
floor_level -= 1
|
||||
return floor_level
|
||||
|
||||
def part2(data: list[str]) -> int:
|
||||
floor_level = 0
|
||||
location_index = 0
|
||||
for i, c in enumerate(data):
|
||||
if c == "(":
|
||||
floor_level += 1
|
||||
else:
|
||||
floor_level -= 1
|
||||
if floor_level == -1:
|
||||
location_index = i
|
||||
break
|
||||
return location_index + 1
|
||||
|
||||
def read_file(filename: str) -> str:
|
||||
with open(filename, 'r') as f:
|
||||
return f.read()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
7
2015/01/python/pyproject.toml
Normal file
7
2015/01/python/pyproject.toml
Normal file
@@ -0,0 +1,7 @@
|
||||
[project]
|
||||
name = "python"
|
||||
version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.13"
|
||||
dependencies = []
|
||||
8
2015/01/python/uv.lock
generated
Normal file
8
2015/01/python/uv.lock
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
version = 1
|
||||
revision = 2
|
||||
requires-python = ">=3.13"
|
||||
|
||||
[[package]]
|
||||
name = "python"
|
||||
version = "0.1.0"
|
||||
source = { virtual = "." }
|
||||
Reference in New Issue
Block a user