This commit is contained in:
2021-12-06 07:37:45 -05:00
commit 6bff0ee551
22 changed files with 5034 additions and 0 deletions

39
Day2_1/main.py Normal file
View File

@@ -0,0 +1,39 @@
from aocd import get_data
from aocd import submit
input_data = get_data(day=2, year=2021)
test_data = """forward 5
down 5
forward 8
up 3
down 8
forward 2"""
lines = input_data.split("\n")
# lines = test_data.split("\n")
def split_line(line):
return line.split(" ")
# print(split_line(lines[0]))
horizontal = 0
depth = 0
for line in lines:
command = split_line(line)
# print(command)
if command[0] == "up":
depth = depth - int(command[1])
if command[0] == "down":
depth = depth + int(command[1])
if command[0] == "forward":
horizontal = horizontal + int(command[1])
print(horizontal)
print(depth)
print(depth*horizontal)
submit(depth*horizontal)

0
Day2_1/promblem.txt Normal file
View File