mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-26 05:10:32 +01:00
Add solutions day 8.
This commit is contained in:
30
day8.py
Normal file
30
day8.py
Normal 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"
|
||||
Reference in New Issue
Block a user