<jupyter_start><jupyter_text>Day 2<jupyter_code>with open("data/day-2.txt") as file:
    lines = [line.strip().split() for line in file.readlines()]

# direction, units
lines[0]<jupyter_output><empty_output><jupyter_text>Part 1<jupyter_code>horizontal_position = 0
depth = 0

for line in lines:
    
    direction, units = line
    
    if direction == "forward":
        horizontal_position += int(units)
    elif direction == "down":
        depth += int(units)
    elif direction == "up":
        depth -= int(units)
    
        
horizontal_position * depth<jupyter_output><empty_output><jupyter_text>Part 2<jupyter_code>horizontal_position = 0
depth = 0
aim = 0

for line in lines:
    
    direction, units = line
    
    if direction == "forward":
        horizontal_position += int(units)  
        depth += aim * int(units)
    elif direction == "down":
        aim += int(units)
    elif direction == "up":
        aim -= int(units)
        

horizontal_position * depth<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12067260138476756, 'fraction_numerical': 0.009891196834817012, 'mean_word_length': 3.0642570281124497, 'pattern_counts': {'":': 6, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '31847', 'license': 'Apache-2.0', 'n_tokens_mistral': 335, 'n_tokens_neox': 327, 'n_words': 75, 'path': '2021/day-2.ipynb', 'repo_name': 'will-rice/aoc', 'size': '1011'}