rename stuff

This commit is contained in:
Maya Herrscher committed 2022-12-03 15:08:59 +01:00
1 parent 7c3d439f6e
commit 97ddc36b62
325 files changed
+85

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env python3
import sys
if __name__ == '__main__':
lines = open(sys.argv[1]).readlines()
dirs = [i.strip('\n').split(" ") for i in lines]
# challenge 1
dep = 0
pos = 0
for d in dirs:
if d[0] == 'forward':
pos += int(d[1])
elif d[0] == 'up':
dep -= int(d[1])
elif d[0] == 'down':
dep += int(d[1])
else:
print(d)
res1 = str(dep * pos)
print("challenge 1:" + res1 + "\n")
# challenge 2
dep = 0
pos = 0
aim = 0
for d in dirs:
if d[0] == 'forward':
pos += int(d[1])
dep += int(d[1]) * aim
elif d[0] == 'up':
aim -= int(d[1])
elif d[0] == 'down':
aim += int(d[1])
else:
print(d)
res2 = str(dep * pos)
print("challenge 2:" + res2 + "\n")