<jupyter_start><jupyter_text>Part 1<jupyter_code>import pandas as pd
df = pd.read_csv('input.txt', header=None, names=["cmd", "value"], sep=" ")
def parseDepth(row):
    if row['cmd'] == 'up':
        return row['value']
    if row['cmd'] == 'down':
        return -row['value']
    return 0

def parseHorizontal(row):
    if row['cmd'] == 'forward':
        return row['value']
    return 0
df['depth'] = df.apply(parseDepth, axis=1)
df['hori'] = df.apply(parseHorizontal, axis=1)
-df.sum()['depth']*df.sum()['hori']<jupyter_output><empty_output><jupyter_text>Part 2<jupyter_code>df = pd.read_csv('input.txt', header=None, names=["cmd", "value"], sep=" ")
def parseAim(row):
    if row['cmd'] == 'up':
        return -row['value']
    if row['cmd'] == 'down':
        return row['value']
    return 0
def parseHorizontal(row):
    if row['cmd'] == 'forward':
        return row['value']
    return 0
def parseDepth(row):
    if row['cmd'] == 'forward':
        return row['value']*row['aim']
    return 0
df['aim'] = df.apply(parseAim, axis=1).cumsum()
df['hori'] = df.apply(parseHorizontal, axis=1)
df['depth'] = df.apply(parseDepth, axis=1)
df.sum()['depth']*df.sum()['hori']<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2144039735099338, 'fraction_numerical': 0.009933774834437087, 'mean_word_length': 4.325991189427313, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '596181', 'license': 'Apache-2.0', 'n_tokens_mistral': 451, 'n_tokens_neox': 441, 'n_words': 89, 'path': '2021/day2/day2.ipynb', 'repo_name': 'totothekiller/advent-of-code', 'size': '1208'}