day 11
This commit is contained in:
@@ -6,7 +6,7 @@ S = { ")": 3, "]": 57, "}": 1197, ">": 25137, }
|
||||
L = sys.stdin.read().splitlines()
|
||||
N = 0
|
||||
for l in L:
|
||||
Q = deque(["y"]*120)
|
||||
Q = deque(["y"]*1)
|
||||
for c in l:
|
||||
p = Q.pop()
|
||||
if c in D: # if closing char
|
||||
|
@@ -1,11 +1,11 @@
|
||||
import sys
|
||||
from collections import deque
|
||||
D = { ">":"<", ")":"(", "]":"[","}":"{", }
|
||||
S = { "(":1, "[":2, "{":3, "<":4, }
|
||||
S = { "(":1, "[":2, "{":3, "<":4, }
|
||||
L = sys.stdin.read().splitlines()
|
||||
N = []
|
||||
for l in L:
|
||||
Q = deque(["y"]*120)
|
||||
Q = deque(["y"]) # add buffer to pop
|
||||
fail = False
|
||||
for c in l:
|
||||
p = Q.pop()
|
||||
@@ -20,7 +20,7 @@ for l in L:
|
||||
Q.append(p)
|
||||
Q.append(c)
|
||||
if not fail:
|
||||
R = list(Q)[120:]
|
||||
R = list(Q)[1:]
|
||||
s = 0
|
||||
for r in reversed(R):
|
||||
s = s*5 + S[r]
|
||||
|
Reference in New Issue
Block a user