Advent of Code 2021 - Day 2

Here is day 2 of my solution for AoC 2021.

if __name__ == "__main__":
	with open("input.txt", "r") as f:
		movements = f.read().split("\n")

	horizontal_pos = 0
	aim_based_depth = 0
	aim = 0

	for movement in movements:
		direction, steps = movement.split(" ")
		steps = int(steps)

		if direction == "forward":
			horizontal_pos += steps
			aim_based_depth += steps * aim
		elif direction == "down":
			aim += steps
		elif direction == "up":
			aim -= steps
	
	print(f"Result for Part 1: {horizontal_pos * aim}")
	print(f"Result for Part 2: {horizontal_pos * aim_based_depth}")

The `depth` value from Part 1 is the same as the `aim` value required for Part 2 so I decided to reuse those. The rest of the solution is simply keeping count of the movement in each line. Once we have the final movements, we multiply them and get the answer.