1
0
Fork 0

2015 day 8 part 2

This commit is contained in:
Lucidiot 2018-12-01 13:13:39 +01:00
parent 8d52f62d14
commit 3dd9ea1f9f
No known key found for this signature in database
GPG Key ID: AE3F7205692FA205
2 changed files with 13 additions and 6 deletions

13
2015/8/len.py Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env python3
import fileinput
def compute(line):
return (
len(line),
len(eval(line)),
len(line.encode('unicode_escape').decode().replace('"', r'\"')) + 2,
)
len_line, len_eval, len_encode = map(sum, zip(*map(compute, map(str.strip, fileinput.input()))))
print(len_line - len_eval, len_encode - len_line)

View File

@ -1,6 +0,0 @@
#!/usr/bin/env python3
import fileinput
len1, len2 = map(sum, zip(*map(lambda x: (len(x), len(eval(x))), map(str.strip, fileinput.input()))))
print(len1 - len2)