# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Part 1

with open('input_day2.txt','r') as file:
    data = file.read().splitlines()


data_split=[x.split(' ') for x in data]

total_x=sum([int(x[1]) for x in data_split if x[0]=='forward'])
total_y=sum([int(x[1]) for x in data_split if x[0]=='down'])-sum([int(x[1]) for x in data_split if x[0]=='up'])

total_x*total_y

# # Part 2 

# +
aim=0
depth=0
x=0
for i in data_split:
    if i[0]=='forward':
        x+=int(i[1])
        depth+=(aim*int(i[1]))        
    elif i[0]=='up':
        aim-=int(i[1])
    elif i[0]=='down':
        aim+=int(i[1])
        
            
# -

x*depth

StarcoderdataJupyterScriptsDedupFiltered