some progress on advent of code

This commit is contained in:
Dmitry Fedotov
2021-12-05 12:32:01 +03:00
parent d9d8dd9598
commit 084a1781f8
6 changed files with 2094 additions and 1 deletions

25
day2_1.py Executable file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/env python3
import sys, utils
def where_are_we_going(l: list):
h, v = 0, 0
for d in l:
d = d.split()
if d[0] == 'forward':
h += int(d[1])
elif d[0] == 'down':
v += int(d[1])
elif d[0] == 'up':
v -= int(d[1])
return h * v
if __name__ == '__main__':
if len(sys.argv) < 2:
print("please supply input file")
sys.exit()
f = utils.File(sys.argv[1])
print(where_are_we_going(f.get_strings()))