#!/usr/bin/python3 def part_1(input): h_pos = 0 depth = 0 for line in input: cmd, rng = line.split() if 'forward' == cmd: h_pos += int(rng) elif 'up' == cmd: depth -= int(rng) elif 'down' == cmd: depth += int(rng) result = h_pos * depth print("Part 1 result:", result) def part_2(input): h_pos = 0 depth = 0 aim = 0 for line in input: cmd, rng = line.split() if 'forward' == cmd: h_pos += int(rng) depth += aim * int(rng) elif 'up' == cmd: aim -= int(rng) elif 'down' == cmd: aim += int(rng) result = h_pos * depth print("Part 2 result:", result) input = list() with open('input.txt') as fp: input = fp.readlines() part_1(input) part_2(input)