aoc

commit 0318496a48cc55d0d371b344e94192cce9af7dea

Author: Honza Pokorny <me@honza.ca>

Part 2 of day 5

 005/main.py | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++


diff --git a/005/main.py b/005/main.py
index 0ed03790528d657ec52d2c1ad24fd1f01c7e0feb..d7fe7f4b4084243fb1116dcf24a0c31087fe4717 100644
--- a/005/main.py
+++ b/005/main.py
@@ -97,16 +97,123 @@                 print(input_list[cur + 1])
             cur += 2
             continue
 
+        if op == '05':
+            mode = front[0]
+            if mode == '0':
+                v = input_list[input_list[cur + 1]]
+            else:
+                v = input_list[cur + 1]
+
+            if v is not 0:
+                m2 = front[1]
+                if m2 == '0':
+                    cur = input_list[input_list[cur + 2]]
+                else:
+                    cur = input_list[cur + 2]
+            else:
+                cur += 3
+
+        if op == '06':
+            mode = front[0]
+            if mode == '0':
+                v = input_list[input_list[cur + 1]]
+            else:
+                v = input_list[cur + 1]
+
+            if v == 0:
+                m2 = front[1]
+                if m2 == '0':
+                    cur = input_list[input_list[cur + 2]]
+                else:
+                    cur = input_list[cur + 2]
+            else:
+                cur += 3
+
+        if op == '07':
+            # 0 po, like before
+            # 1 im
+            a_mode = front[0]
+            b_mode = front[1]
+
+            if a_mode == '0':
+                a = input_list[input_list[cur + 1]]
+            else:
+                a = input_list[cur + 1]
+
+            if b_mode == '0':
+                b = input_list[input_list[cur + 2]]
+            else:
+                b = input_list[cur + 2]
+
+            result_pos = input_list[cur + 3]
+
+            if a < b:
+                input_list[result_pos] = 1
+            else:
+                input_list[result_pos] = 0
+
+            cur += 4
+            continue
+
+        if op == '08':
+            # 0 po, like before
+            # 1 im
+            a_mode = front[0]
+            b_mode = front[1]
+
+            if a_mode == '0':
+                a = input_list[input_list[cur + 1]]
+            else:
+                a = input_list[cur + 1]
+
+            if b_mode == '0':
+                b = input_list[input_list[cur + 2]]
+            else:
+                b = input_list[cur + 2]
+
+            result_pos = input_list[cur + 3]
+
+            if a == b:
+                input_list[result_pos] = 1
+            else:
+                input_list[result_pos] = 0
+
+            cur += 4
+            continue
+
 
 def main():
     input_list = [
 
-        3,225,1,225,6,6,1100,1,238,225,104,0,1102,45,16,225,2,65,191,224,1001,224,-3172,224,4,224,102,8,223,223,1001,224,5,224,1,223,224,223,1102,90,55,225,101,77,143,224,101,-127,224,224,4,224,102,8,223,223,1001,224,7,224,1,223,224,223,1102,52,6,225,1101,65,90,225,1102,75,58,225,1102,53,17,224,1001,224,-901,224,4,224,1002,223,8,223,1001,224,3,224,1,224,223,223,1002,69,79,224,1001,224,-5135,224,4,224,1002,223,8,223,1001,224,5,224,1,224,223,223,102,48,40,224,1001,224,-2640,224,4,224,102,8,223,223,1001,224,1,224,1,224,223,223,1101,50,22,225,1001,218,29,224,101,-119,224,224,4,224,102,8,223,223,1001,224,2,224,1,223,224,223,1101,48,19,224,1001,224,-67,224,4,224,102,8,223,223,1001,224,6,224,1,223,224,223,1101,61,77,225,1,13,74,224,1001,224,-103,224,4,224,1002,223,8,223,101,3,224,224,1,224,223,223,1102,28,90,225,4,223,99,0,0,0,677,0,0,0,0,0,0,0,0,0,0,0,1105,0,99999,1105,227,247,1105,1,99999,1005,227,99999,1005,0,256,1105,1,99999,1106,227,99999,1106,0,265,1105,1,99999,1006,0,99999,1006,227,274,1105,1,99999,1105,1,280,1105,1,99999,1,225,225,225,1101,294,0,0,105,1,0,1105,1,99999,1106,0,300,1105,1,99999,1,225,225,225,1101,314,0,0,106,0,0,1105,1,99999,7,226,677,224,102,2,223,223,1005,224,329,1001,223,1,223,8,226,677,224,1002,223,2,223,1005,224,344,101,1,223,223,8,226,226,224,1002,223,2,223,1006,224,359,101,1,223,223,1008,677,226,224,1002,223,2,223,1005,224,374,1001,223,1,223,108,677,677,224,1002,223,2,223,1005,224,389,1001,223,1,223,1107,226,677,224,1002,223,2,223,1006,224,404,101,1,223,223,1008,226,226,224,102,2,223,223,1006,224,419,1001,223,1,223,7,677,226,224,1002,223,2,223,1005,224,434,101,1,223,223,1108,226,226,224,1002,223,2,223,1005,224,449,101,1,223,223,7,226,226,224,102,2,223,223,1005,224,464,101,1,223,223,108,677,226,224,102,2,223,223,1005,224,479,1001,223,1,223,1007,677,226,224,1002,223,2,223,1006,224,494,1001,223,1,223,1007,677,677,224,1002,223,2,223,1006,224,509,1001,223,1,223,107,677,677,224,1002,223,2,223,1005,224,524,101,1,223,223,1108,226,677,224,102,2,223,223,1006,224,539,1001,223,1,223,8,677,226,224,102,2,223,223,1005,224,554,101,1,223,223,1007,226,226,224,102,2,223,223,1006,224,569,1001,223,1,223,107,677,226,224,102,2,223,223,1005,224,584,1001,223,1,223,108,226,226,224,102,2,223,223,1006,224,599,1001,223,1,223,107,226,226,224,1002,223,2,223,1006,224,614,1001,223,1,223,1108,677,226,224,1002,223,2,223,1005,224,629,1001,223,1,223,1107,677,677,224,102,2,223,223,1005,224,644,1001,223,1,223,1008,677,677,224,102,2,223,223,1005,224,659,101,1,223,223,1107,677,226,224,1002,223,2,223,1006,224,674,101,1,223,223,4,223,99,226
+        3,225,1,225,6,6,1100,1,238,225,104,0,1102,45,16,225,2,65,191,224,1001,
+        224,-3172,224,4,224,102,8,223,223,1001,224,5,224,1,223,224,223,1102,
+        90,55,225,101,77,143,224,101,-127,224,224,4,224,102,8,223,223,1001,224,
+        7,224,1,223,224,223,1102,52,6,225,1101,65,90,225,1102,75,58,225,1102,
+        53,17,224,1001,224,-901,224,4,224,1002,223,8,223,1001,224,3,224,1,224,
+        223,223,1002,69,79,224,1001,224,-5135,224,4,224,1002,223,8,223,1001,
+        224,5,224,1,224,223,223,102,48,40,224,1001,224,-2640,224,4,224,
+        102,8,223,223,1001,224,1,224,1,224,223,223,1101,50,22,225,1001,218,29,
+        224,101,-119,224,224,4,224,102,8,223,223,1001,224,2,224,1,223,224,223,
+
+
+        1101,48,19,224,1001,224,-67,224,4,224,102,8,223,223,1001,224,6,224,1,
+
+        223,224,223,1101,61,77,225,1,13,74,224,1001,224,-103,224,4,224,1002,223,8,223,101,3,224,224,1,224,223,223,1102,28,90,225,4,223,99,0,0,0,677,0,0,0,0,0,0,0,0,0,0,0,1105,0,99999,1105,227,247,1105,1,
+        99999,1005,227,99999,1005,0,256,1105,1,99999,1106,227,99999,1106,0,265,1105,1,99999,1006,0,99999,1006,227,274,1105,1,99999,1105,1,280,1105,1,99999,1,225,225,225,1101,294,0,0,105,1,0,1105,1,99999,
+        1106,0,300,1105,1,99999,1,225,225,225,1101,314,0,0,106,0,0,1105,1,99999,7,226,677,224,102,2,223,223,1005,224,329,1001,223,1,223,8,226,677,224,1002,223,2,223,1005,224,344,101,1,223,223,8,226,226,224,
+        1002,223,2,223,1006,224,359,101,1,223,223,1008,677,226,224,1002,223,2,223,1005,224,374,1001,223,1,223,108,677,677,224,1002,223,2,223,1005,224,389,1001,223,1,223,1107,226,677,224,1002,223,2,
+
+        223,1006,224,404,101,1,223,223,1008,226,226,224,102,2,223,223,1006,224,419,1001,223,1,223,7,677,226,224,1002,223,2,223,1005,224,434,101,1,223,223,1108,226,226,224,1002,223,2,223,1005,224,449,
+        101,1,223,223,7,226,226,224,102,2,223,223,1005,224,464,101,1,223,223,108,677,226,224,102,2,223,223,1005,224,479,1001,223,1,223,1007,677,226,224,1002,223,2,223,1006,224,494,1001,223,1,223,1007,
+        677,677,224,1002,223,2,223,1006,224,509,1001,223,1,223,107,677,677,224,1002,223,2,223,1005,224,524,101,1,223,223,1108,226,677,224,102,2,223,223,1006,224,539,1001,223,1,223,8,677,226,224,102,2,
+        223,223,1005,224,554,101,1,223,223,1007,226,226,224,102,2,223,223,1006,224,569,1001,223,1,223,107,677,226,224,102,2,223,223,1005,224,584,1001,223,1,223,108,226,226,224,102,2,223,223,1006,224,599,
+        1001,223,1,223,107,226,226,224,1002,223,2,223,1006,224,614,1001,223,1,223,1108,677,226,224,1002,223,2,223,1005,224,629,1001,223,1,223,1107,677,677,224,102,2,223,223,1005,224,644,1001,223,1,223,
+        1008,677,677,224,102,2,223,223,1005,224,659,101,1,223,223,1107,677,226,224,1002,223,2,223,1006,224,674,101,1,223,223,4,223,99,226
 
 
     ]
 
-    intcode(input_list, 1)
+    intcode(input_list, 5)