36 lines
615 B
Python
36 lines
615 B
Python
# Fill Input
|
|
|
|
try:
|
|
with open("08.txt", 'r', encoding='utf-8') as file:
|
|
input = file.read()
|
|
except Exception as e:
|
|
print(f"An error occurred: {e}")
|
|
|
|
# Result
|
|
res1, res2 = 0, 0
|
|
for line in input.split('\n'):
|
|
#for line in ["\"\"", "\"abc\"", "\"aaa\\\"aaa\"", "\"\\x27\""]:
|
|
#res2 = 0
|
|
it = iter(line)
|
|
while c:=next(it, None):
|
|
match c:
|
|
case '\"':
|
|
res1+=1
|
|
res2+= 1
|
|
pass
|
|
case '\\':
|
|
res1+=1
|
|
res2+=1
|
|
match c:= next(it):
|
|
case 'x':
|
|
next(it)
|
|
next(it)
|
|
res1+=2
|
|
case '\"':
|
|
res2+=1
|
|
case _:
|
|
pass
|
|
res2+=2
|
|
print(res1, res2+len(line))
|
|
print(res1, res2)
|