You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
557 B
Python
26 lines
557 B
Python
3 years ago
|
with open("input") as f:
|
||
|
lines = [n.strip() for n in f.readlines()]
|
||
|
|
||
|
solution = 0
|
||
|
|
||
|
for line in lines:
|
||
|
char_count = 0
|
||
|
i = 1
|
||
|
while i < len(line) - 1:
|
||
|
char = line[i]
|
||
|
if char == "\\":
|
||
|
next_char = line[i + 1]
|
||
|
if next_char in ["\\", '"']:
|
||
|
i += 1
|
||
|
elif next_char in ["x"]:
|
||
|
i += 3
|
||
|
char_count += 1
|
||
|
i += 1
|
||
|
|
||
|
literal_count = len(line)
|
||
|
|
||
|
print(f"{line}: {literal_count=}, {char_count=}")
|
||
|
solution += literal_count - char_count
|
||
|
|
||
|
print(solution)
|