advent-of-code/2015/08/part2.py

22 lines
466 B
Python
Raw Normal View History

2021-12-01 11:07:21 +01:00
with open("input") as f:
lines = [n.strip() for n in f.readlines()]
solution = 0
for line in lines:
literal_count = len(line)
char_count = 2 # surrounding double quotes: '"'
i = 0
while i < len(line):
char = line[i]
if char in ['"', "\\", ""]:
char_count += 1
char_count += 1
i += 1
print(f"{line}: {literal_count=}, {char_count=}")
solution += char_count - literal_count
print(solution)