Skip to content

Instantly share code, notes, and snippets.

@TheSkorm
Created December 10, 2015 03:15
Show Gist options
  • Select an option

  • Save TheSkorm/683bf8d1fbe0fbea8c61 to your computer and use it in GitHub Desktop.

Select an option

Save TheSkorm/683bf8d1fbe0fbea8c61 to your computer and use it in GitHub Desktop.
f = open('Downloads/input.txt', 'r')
chars=0
memory=0
for line in f:
print bytes(line[:-1])
print len(bytes(line[:-1]))
print len(line.decode('string_escape'))-3
memory += len(bytes(line[:-1]))
chars += len(line.decode('string_escape'))-3
print memory - chars
f = open('Downloads/input.txt', 'r')
chars=0
memory=0
for line in f:
print bytes(line[:-1])
print len(bytes(line[:-1]))
print len('"'+ line[:-1].replace("\\","\\\\").replace("\"","\\\"") + '"')
memory += len(bytes(line[:-1]))
chars += len('"'+ line[:-1].replace("\\","\\\\").replace("\"","\\\"") + '"')
print chars - memory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment