mirror of
https://github.com/ershisan99/advent-of-code.git
synced 2025-12-16 12:32:49 +00:00
2015 day 1 part 1 refactor
This commit is contained in:
@@ -1,15 +1,9 @@
|
||||
import os
|
||||
|
||||
script_dir = os.path.dirname(__file__) # <-- absolute dir the script is in
|
||||
rel_path = "./input.txt"
|
||||
abs_file_path = os.path.join(script_dir, rel_path)
|
||||
abs_file_path = os.path.join(os.path.dirname(__file__), "./input.txt")
|
||||
|
||||
input = open(abs_file_path).read()
|
||||
input = open(abs_file_path).read().strip()
|
||||
|
||||
count = 0
|
||||
for i, char in enumerate(list(input), start=1):
|
||||
if char == "(":
|
||||
count += 1
|
||||
else:
|
||||
count -= 1
|
||||
print(count)
|
||||
result = input.count("(") - input.count(")")
|
||||
|
||||
print(result)
|
||||
|
||||
Reference in New Issue
Block a user