We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 88f50d0 commit 6711898Copy full SHA for 6711898
2b.py
@@ -4,7 +4,7 @@
4
# import sys
5
# import re
6
7
-filename = "data2_short.txt"
+filename = "data2.txt"
8
9
file = open(filename)
10
filestr = file.read()
@@ -14,16 +14,16 @@
14
15
depth = 0
16
hpos = 0
17
+aim = 0
18
for line in a_list:
19
match line.split():
- #cmd_val = line.split(" ")
20
- #val = int(cmd_val[1])
21
case "forward", val:
22
hpos += int(val)
+ depth += aim*(int(val))
23
case "down", val:
24
- depth += int(val)
+ aim += int(val)
25
case "up", val:
26
- depth -= int(val)
+ aim -= int(val)
27
case _:
28
print(f"error: {line}")
29
exit()
0 commit comments