Day 19 (cleanup)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
import re
|
||||
|
||||
lines = (x.strip() for x in open("input.txt"))
|
||||
rules = {}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
import re
|
||||
|
||||
lines = (x.strip() for x in open("input.txt"))
|
||||
rules = {}
|
||||
@@ -15,7 +14,8 @@ def yield_rule(line, rule, depth):
|
||||
|
||||
|
||||
def check(line, idx, depth=0):
|
||||
if depth <= 100:
|
||||
if depth > 100:
|
||||
return
|
||||
rs = rules[idx]
|
||||
if isinstance(rs, str):
|
||||
if line.startswith(rs):
|
||||
@@ -27,7 +27,7 @@ def check(line, idx, depth=0):
|
||||
|
||||
sum = 0
|
||||
for line in lines:
|
||||
line = '11: 42 31 | 42 11 31' if line.startswith('11: ') else line
|
||||
line = '11: 42 31 | 42 11 31' if line.startswith('11:') else line
|
||||
line = '8: 42 | 42 8' if line.startswith('8:') else line
|
||||
if ":" in line:
|
||||
idx, r = line.split(": ")
|
||||
|
||||
Reference in New Issue
Block a user