diff options
author | j-james | 2021-12-02 05:06:58 +0000 |
---|---|---|
committer | j-james | 2021-12-02 08:58:29 +0000 |
commit | 4998c58a68c71101e63133bb5501b28be72093c7 (patch) | |
tree | ac82ad15558312b322bd332605454abf315a22c0 /2021 | |
parent | d325ab6752b37294ce62918c797ff30084bcf0b4 (diff) |
Day Two
Diffstat (limited to '2021')
-rw-r--r-- | 2021/02.py | 30 | ||||
-rw-r--r-- | 2021/input/02.txt | 1000 |
2 files changed, 1030 insertions, 0 deletions
diff --git a/2021/02.py b/2021/02.py new file mode 100644 index 0000000..2489b90 --- /dev/null +++ b/2021/02.py @@ -0,0 +1,30 @@ +# Day Two: Dive! + +file = open("input/02.txt").readlines() + +hori = 0 +depth = 0 + +for line in file: + com = line.split() + if com[0] == "forward": + hori += int(com[1]) + if com[0] == "up": + depth -= int(com[1]) + if com[0] == "down": + depth += int(com[1]) +print(hori * depth) + +hori = 0 +depth = 0 +aim = 0 +for line in file: + com = line.split() + if com[0] == "forward": + hori += int(com[1]) + depth += aim * int(com[1]) + if com[0] == "up": + aim -= int(com[1]) + if com[0] == "down": + aim += int(com[1]) +print(hori * depth) diff --git a/2021/input/02.txt b/2021/input/02.txt new file mode 100644 index 0000000..7834464 --- /dev/null +++ b/2021/input/02.txt @@ -0,0 +1,1000 @@ +forward 8 +forward 9 +forward 9 +down 3 +forward 9 +down 1 +down 7 +down 7 +down 4 +down 2 +down 6 +down 6 +down 2 +forward 6 +forward 6 +forward 2 +forward 2 +forward 7 +forward 6 +up 6 +up 8 +forward 5 +forward 4 +down 6 +forward 7 +down 5 +forward 5 +down 8 +down 8 +down 7 +forward 4 +down 2 +forward 7 +up 8 +forward 3 +down 2 +forward 1 +up 3 +forward 3 +up 1 +down 3 +up 7 +up 2 +down 4 +down 2 +forward 9 +forward 3 +down 8 +forward 5 +up 9 +up 4 +forward 9 +down 1 +forward 6 +down 3 +forward 8 +up 2 +forward 3 +up 7 +down 4 +forward 2 +forward 7 +forward 3 +down 1 +down 3 +up 5 +forward 6 +down 5 +down 4 +down 8 +down 2 +up 5 +forward 7 +up 8 +forward 2 +down 5 +forward 3 +up 1 +up 5 +down 8 +down 3 +forward 4 +forward 4 +forward 1 +up 8 +down 9 +forward 7 +forward 9 +down 5 +up 3 +down 9 +up 6 +forward 1 +forward 3 +forward 5 +down 5 +forward 6 +down 3 +down 8 +forward 3 +forward 5 +forward 7 +forward 6 +down 9 +down 5 +down 6 +down 5 +down 1 +down 8 +forward 3 +down 9 +down 5 +down 5 +forward 9 +forward 2 +down 7 +forward 9 +forward 9 +up 1 +forward 3 +up 9 +forward 5 +forward 7 +down 7 +forward 2 +up 8 +up 6 +down 7 +down 3 +down 5 +down 2 +forward 6 +forward 6 +up 6 +up 2 +forward 4 +forward 7 +forward 1 +down 4 +up 8 +down 3 +up 1 +down 2 +forward 4 +forward 7 +up 1 +down 7 +forward 8 +up 2 +down 8 +up 4 +up 4 +up 2 +down 8 +up 4 +down 6 +up 8 +down 5 +up 5 +down 8 +forward 9 +down 1 +down 5 +forward 3 +forward 3 +up 9 +down 2 +forward 3 +down 6 +forward 1 +forward 9 +forward 3 +down 8 +up 4 +down 1 +down 8 +up 1 +forward 2 +down 7 +up 3 +up 8 +down 2 +up 6 +forward 6 +down 9 +forward 4 +forward 7 +up 9 +forward 3 +forward 2 +down 8 +down 2 +down 5 +down 5 +down 1 +up 7 +down 4 +forward 5 +down 9 +down 5 +down 1 +down 6 +forward 9 +down 6 +forward 3 +down 3 +up 6 +forward 2 +forward 6 +down 2 +down 9 +down 6 +down 1 +down 7 +down 6 +down 6 +up 1 +forward 8 +down 9 +down 6 +down 8 +down 8 +down 6 +down 3 +forward 9 +forward 6 +down 9 +forward 5 +down 6 +down 6 +down 9 +down 7 +down 3 +forward 1 +up 9 +forward 9 +down 7 +forward 4 +down 1 +forward 9 +up 9 +down 7 +forward 5 +down 3 +up 7 +forward 9 +forward 6 +forward 3 +forward 8 +down 4 +down 1 +down 7 +down 7 +up 4 +down 9 +forward 6 +forward 7 +down 8 +forward 2 +forward 2 +forward 9 +forward 6 +forward 9 +up 6 +up 8 +forward 2 +up 3 +forward 9 +forward 1 +down 4 +forward 8 +down 4 +forward 5 +forward 7 +up 2 +forward 5 +down 4 +forward 3 +down 5 +forward 9 +up 3 +forward 8 +down 7 +down 7 +down 9 +forward 2 +down 1 +down 6 +up 8 +down 2 +down 1 +up 3 +down 3 +forward 2 +forward 6 +up 6 +down 3 +up 9 +up 3 +down 8 +up 6 +down 2 +forward 4 +up 1 +down 5 +down 4 +up 9 +up 7 +forward 7 +down 9 +forward 9 +forward 5 +forward 3 +down 4 +up 6 +up 7 +down 7 +down 6 +up 9 +up 4 +down 7 +forward 7 +forward 8 +down 9 +forward 5 +forward 4 +down 5 +forward 8 +forward 5 +up 3 +down 9 +forward 1 +forward 2 +up 3 +down 2 +down 1 +forward 5 +forward 5 +forward 6 +up 2 +forward 3 +down 7 +down 6 +up 3 +down 4 +down 4 +forward 5 +down 3 +up 6 +forward 1 +up 8 +forward 7 +forward 1 +forward 9 +down 2 +up 8 +up 1 +up 4 +forward 9 +forward 3 +forward 5 +down 1 +up 9 +down 1 +forward 3 +down 6 +down 8 +up 4 +forward 6 +up 7 +down 8 +forward 9 +up 2 +down 7 +down 1 +forward 9 +up 7 +forward 3 +forward 9 +forward 1 +forward 1 +down 9 +forward 1 +up 4 +down 5 +forward 4 +down 1 +forward 4 +forward 9 +up 4 +down 3 +down 6 +up 2 +down 6 +down 5 +forward 5 +up 1 +up 9 +forward 8 +up 3 +down 1 +forward 3 +forward 7 +up 6 +up 3 +down 6 +forward 7 +up 6 +down 7 +forward 8 +up 4 +down 8 +up 9 +up 3 +down 3 +forward 8 +down 4 +down 9 +forward 2 +down 7 +up 1 +forward 9 +forward 5 +up 8 +forward 9 +forward 4 +forward 9 +forward 7 +down 4 +up 4 +down 7 +down 4 +down 4 +down 1 +forward 5 +forward 4 +down 1 +down 4 +down 8 +down 3 +forward 7 +forward 4 +down 1 +down 9 +up 3 +forward 2 +down 8 +down 9 +down 2 +down 5 +up 9 +down 9 +up 9 +forward 5 +forward 8 +forward 9 +down 5 +forward 6 +down 8 +down 9 +forward 8 +up 5 +up 9 +up 7 +up 8 +forward 9 +forward 1 +up 6 +down 8 +down 8 +forward 1 +up 1 +forward 8 +forward 6 +down 4 +forward 1 +down 7 +forward 8 +forward 3 +up 3 +down 4 +down 2 +forward 2 +forward 3 +up 4 +down 3 +forward 2 +down 8 +forward 7 +up 3 +down 2 +forward 2 +down 5 +up 6 +up 6 +forward 4 +up 4 +down 8 +forward 8 +down 9 +down 9 +down 6 +down 2 +forward 2 +up 6 +up 5 +forward 3 +forward 3 +up 9 +down 3 +forward 8 +down 5 +forward 5 +forward 7 +down 3 +down 4 +down 1 +down 8 +down 1 +down 1 +forward 9 +forward 3 +down 8 +down 6 +up 9 +forward 1 +forward 5 +up 9 +up 8 +forward 2 +up 8 +down 9 +up 2 +forward 5 +forward 1 +forward 8 +down 3 +forward 4 +down 5 +up 6 +forward 8 +forward 9 +forward 3 +down 1 +down 3 +down 3 +up 4 +forward 9 +down 3 +down 6 +forward 3 +forward 2 +down 6 +down 8 +forward 6 +up 8 +up 3 +up 4 +forward 2 +forward 4 +forward 4 +forward 7 +down 6 +up 8 +down 3 +forward 8 +forward 4 +down 7 +down 5 +forward 6 +forward 4 +forward 6 +down 3 +forward 3 +down 1 +down 7 +forward 3 +forward 2 +forward 7 +down 5 +up 4 +down 6 +down 9 +forward 3 +forward 5 +forward 3 +down 1 +forward 2 +up 5 +up 6 +forward 2 +down 4 +forward 3 +down 4 +down 1 +forward 8 +up 2 +down 3 +down 6 +up 5 +forward 3 +forward 6 +down 3 +forward 1 +down 7 +forward 2 +forward 1 +forward 6 +forward 5 +forward 3 +down 4 +down 8 +forward 1 +up 2 +up 8 +down 4 +forward 9 +up 6 +forward 5 +forward 7 +down 5 +forward 5 +down 1 +forward 4 +forward 5 +up 2 +forward 5 +up 8 +up 1 +forward 2 +down 4 +down 6 +forward 4 +down 2 +down 3 +forward 2 +up 3 +up 4 +forward 2 +down 6 +forward 1 +forward 4 +down 6 +forward 7 +up 2 +forward 7 +forward 6 +up 2 +forward 8 +forward 4 +forward 9 +down 1 +down 8 +forward 3 +forward 2 +down 8 +up 1 +forward 4 +down 8 +forward 2 +forward 8 +up 2 +down 1 +forward 4 +forward 2 +up 4 +up 2 +down 3 +up 8 +forward 3 +up 8 +forward 9 +up 1 +up 5 +down 5 +down 6 +forward 1 +up 5 +up 8 +forward 7 +down 5 +up 4 +forward 2 +up 4 +up 4 +down 2 +forward 6 +forward 2 +down 7 +down 5 +forward 1 +down 2 +down 5 +down 7 +up 8 +down 8 +up 5 +down 1 +forward 5 +down 2 +forward 5 +down 1 +up 7 +up 2 +forward 2 +forward 3 +forward 6 +forward 3 +down 8 +up 8 +forward 8 +forward 1 +forward 7 +up 2 +forward 9 +down 1 +forward 5 +up 9 +forward 3 +forward 7 +forward 8 +up 1 +down 3 +forward 5 +down 2 +forward 6 +forward 3 +down 9 +up 5 +forward 2 +down 4 +up 1 +forward 4 +up 4 +down 8 +down 8 +forward 3 +forward 8 +down 7 +up 3 +forward 1 +up 3 +forward 9 +forward 7 +forward 1 +down 6 +forward 3 +down 1 +down 8 +forward 5 +forward 3 +up 6 +forward 5 +forward 4 +forward 3 +forward 9 +forward 8 +down 6 +down 2 +forward 7 +forward 6 +up 6 +down 6 +down 4 +down 3 +forward 8 +down 9 +up 5 +forward 3 +forward 2 +down 5 +up 4 +down 6 +down 3 +forward 9 +down 2 +forward 9 +forward 8 +up 1 +down 2 +forward 7 +up 5 +up 6 +down 8 +up 9 +up 8 +forward 1 +forward 5 +down 9 +forward 8 +down 8 +up 1 +down 7 +forward 7 +up 3 +down 3 +down 1 +forward 2 +down 3 +forward 9 +forward 2 +down 8 +down 2 +forward 5 +down 9 +down 1 +down 5 +down 6 +up 4 +up 3 +down 1 +up 7 +forward 6 +down 3 +down 6 +up 5 +forward 8 +up 8 +down 1 +down 2 +up 8 +down 7 +forward 7 +forward 4 +down 8 +down 3 +forward 3 +down 4 +forward 3 +down 6 +forward 4 +forward 7 +forward 9 +up 7 +forward 1 +down 7 +down 8 +down 8 +up 6 +down 3 +forward 5 +forward 5 +forward 9 +forward 4 +down 4 +down 8 +down 7 +down 1 +forward 2 +forward 4 +down 3 +down 6 +down 7 +forward 5 +down 8 +down 1 +forward 4 +forward 3 +forward 1 +down 6 +down 7 +down 1 +forward 6 +down 4 +up 2 +forward 4 +down 2 +up 5 +down 2 +down 6 +up 7 +forward 4 +forward 7 +forward 9 +up 5 +down 9 +up 5 +forward 6 +down 2 +up 8 +up 9 +up 9 +forward 5 +down 2 +forward 2 +down 7 +forward 5 +forward 9 +up 8 +down 8 +forward 1 +down 2 +up 3 +forward 3 +down 5 +forward 4 +down 3 +forward 4 +forward 9 +forward 3 +down 5 +forward 4 +down 2 +forward 5 +forward 8 +up 6 +up 2 +down 3 +forward 6 +down 5 +down 4 +down 4 +down 4 +up 2 +up 2 +forward 6 +forward 2 +forward 9 +down 2 +down 9 +down 8 +forward 2 +down 3 +up 3 +forward 5 +down 4 +up 3 +forward 3 +down 1 +forward 7 +forward 5 +forward 6 +down 8 +down 5 +down 5 +down 9 +up 2 +forward 3 +down 4 +down 9 +forward 3 +forward 9 +forward 2 +forward 4 +up 6 +down 6 +up 9 +forward 8 +down 7 +forward 1 +forward 4 +up 1 +up 2 +down 9 +forward 6 +down 6 +down 1 +down 4 +down 7 +down 6 +forward 5 +up 1 +up 7 +down 2 +down 8 +down 2 +down 7 +down 3 +up 9 +down 7 +down 5 +down 6 +forward 9 +up 3 +forward 2 +down 8 +forward 4 +down 6 +forward 3 +up 3 +down 5 +up 4 +forward 6 +forward 7 +forward 9 +down 3 +forward 7 +forward 3 +down 4 +up 4 +down 8 +forward 6 +forward 7 +forward 9 +forward 4 +down 3 +up 5 +down 7 +down 7 +forward 9 |