Initial commit

This commit is contained in:
2023-07-07 00:47:08 -04:00
commit 6f916c29d1
43 changed files with 13417 additions and 0 deletions

32
2021/day2.py Executable file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/env python3
def main():
with open('day2', 'r') as file:
lines = file.readlines()
position = 0
depth = 0
position_2 = 0
depth_2 = 0
aim = 0
for line in lines:
command = line.split()
match command[0]:
case 'forward':
position += int(command[1])
position_2 += int(command[1])
depth_2 += aim * int(command[1])
case 'up':
depth -= int(command[1])
aim -= int(command[1])
case 'down':
depth += int(command[1])
aim += int(command[1])
print(position * depth)
print(position_2 * depth_2)
if __name__ == '__main__':
main()