Add solutions day 8.

This commit is contained in:
Bert Peters
2015-12-08 13:39:01 +01:00
parent 719e8bb51d
commit 8329f06582
2 changed files with 330 additions and 0 deletions

30
day8.py Normal file
View File

@@ -0,0 +1,30 @@
import fileinput
import re
totalLess = 0
totalMore = 0
for line in fileinput.input():
original = len(line)
diff = 2
plus = 2
escaped = False
for c in line:
if c == "\\" or c == "\"":
plus += 1
if c == "\\" and not escaped:
escaped = True
diff += 1
continue
if escaped and c == "x":
diff += 2
escaped = False
totalLess += diff
totalMore += plus
print totalLess, "less"
print totalMore, "more"