<jupyter_start><jupyter_text>Day 10<jupyter_code>from aocd.models import Puzzle<jupyter_output><empty_output><jupyter_text>Data<jupyter_code>puzzle = Puzzle(year=2021, day=10)
data = puzzle.input_data.split()<jupyter_output><empty_output><jupyter_text>Part One<jupyter_code>pairs = {
    '(': ')',
    '[': ']',
    '{': '}',
    '<': '>',
}
points = {    
    ')': 3,
    ']': 57,
    '}': 1197,
    '>': 25137,
}
score = 0
broken = []
for i, d in enumerate(data):
    chunks = []
    for c in d:
        if c in pairs.keys():
            chunks.append(c)
        elif c in pairs.values():
            if c == pairs[chunks[-1]]:
                chunks.pop()
            else:
                score += points[c]
                broken.append(i)  # Register broken lines
                break
answer_a = score
answer_a
puzzle.answer_a = answer_a<jupyter_output>[32mThat's the right answer!  You are one gold star closer to finding the sleigh keys. [Continue to Part Two][0m<jupyter_text>Part Two<jupyter_code>points2 = {    
    ')': 1,
    ']': 2,
    '}': 3,
    '>': 4,
}
lscore = []
for i, d in enumerate(data):
    if i in broken:
        continue
    chunks = []
    pscore = 0
    for c in d:
        if c in pairs.keys():
            chunks.append(c)
        else:
            chunks.pop()
    for c in chunks[::-1]:
        pscore *= 5
        pscore += points2[pairs[c]]
    lscore.append(pscore)
lscore.sort()
answer_b = lscore[len(lscore)//2]
answer_b
puzzle.answer_b = answer_b
import scooby
scooby.Report('aocd')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15285806037251123, 'fraction_numerical': 0.0224791265253693, 'mean_word_length': 2.4091903719912473, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '602840', 'license': 'Apache-2.0', 'n_tokens_mistral': 617, 'n_tokens_neox': 580, 'n_words': 120, 'path': '2021/Day-10.ipynb', 'repo_name': 'prisae/aoc20', 'size': '1557'}