Cleanup
This commit is contained in:
parent
a5620c8197
commit
54d110bddb
|
@ -9,7 +9,6 @@ proc p1(s: seq[string]): int =
|
||||||
if p.hasKey(c): stack.add(p[c])
|
if p.hasKey(c): stack.add(p[c])
|
||||||
else:
|
else:
|
||||||
if stack.pop() != c: result += t[c]
|
if stack.pop() != c: result += t[c]
|
||||||
echo result
|
|
||||||
|
|
||||||
const v = {')': 1, ']': 2, '}': 3, '>': 4}.toTable()
|
const v = {')': 1, ']': 2, '}': 3, '>': 4}.toTable()
|
||||||
proc p2(s: seq[string]): int =
|
proc p2(s: seq[string]): int =
|
||||||
|
@ -24,16 +23,12 @@ proc p2(s: seq[string]): int =
|
||||||
score = -1
|
score = -1
|
||||||
break
|
break
|
||||||
if score == -1: continue
|
if score == -1: continue
|
||||||
echo stack
|
|
||||||
for l in stack.reversed():
|
for l in stack.reversed():
|
||||||
score *= 5
|
score *= 5
|
||||||
score += v[l]
|
score += v[l]
|
||||||
echo score
|
|
||||||
scores.add(score)
|
scores.add(score)
|
||||||
scores.sort()
|
scores.sort()
|
||||||
echo scores
|
|
||||||
result = scores[(scores.len() div 2)]
|
result = scores[(scores.len() div 2)]
|
||||||
echo result
|
|
||||||
|
|
||||||
doDay(10, (n) => n.loadInput(),
|
doDay(10, (n) => n.loadInput(),
|
||||||
p1,
|
p1,
|
||||||
|
|
Loading…
Reference in a new issue