26 lines
536 B
Python
26 lines
536 B
Python
from lib import get_data
|
|
import re
|
|
|
|
data = get_data(__file__)
|
|
|
|
r1 = re.compile(r"\\x[0-9a-f][0-9a-f]")
|
|
r2 = re.compile(r"\\\\")
|
|
r3 = re.compile(r"\\\"")
|
|
|
|
enc, mem = 0, 0
|
|
for line in data.splitlines():
|
|
mem += len(line)
|
|
line = r1.sub("^", line)
|
|
line = r2.sub("^", line)
|
|
line = r3.sub("^", line)
|
|
enc += len(line) - 2
|
|
print(mem - enc)
|
|
|
|
ori, enc = 0, 0
|
|
for line in data.splitlines():
|
|
ori += len(line)
|
|
line = line.replace("\\", "\\\\")
|
|
line = line.replace('"', '\\"')
|
|
enc += len(line) + 2
|
|
print(enc - ori)
|