summaryrefslogtreecommitdiffstats
path: root/solutions/py/d05.py
diff options
context:
space:
mode:
authorGustav Sörnäs <gusso230@student.liu.se>2019-12-08 11:06:56 +0100
committerGustav Sörnäs <gusso230@student.liu.se>2019-12-08 11:06:56 +0100
commit29e33f8f6a31565f5a2671b1c459ff1b829630f7 (patch)
treec051274a9e9a895049a077a6bdce9056dfb9afb1 /solutions/py/d05.py
parentd16fc72a33fced8c8623bea6cf9cdd9cf8999024 (diff)
downloadaoc-29e33f8f6a31565f5a2671b1c459ff1b829630f7.tar.gz
Refactor and create main.py
Diffstat (limited to 'solutions/py/d05.py')
-rw-r--r--solutions/py/d05.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/solutions/py/d05.py b/solutions/py/d05.py
new file mode 100644
index 0000000..446bcd6
--- /dev/null
+++ b/solutions/py/d05.py
@@ -0,0 +1,26 @@
+import intcode
+
+def pt1(input):
+ program = [int(x) for x in input[0].split(",")]
+ c = intcode.Computer(program)
+ c.input = 1
+ output = []
+ while c.memory[c.pointer] != 99:
+ c.step()
+ if c.output != None:
+ output.append(c.output)
+ c.output = None
+ return output
+
+def pt2(input):
+ program = [int(x) for x in input[0].split(",")]
+ c = intcode.Computer(program)
+ c.input = 5
+ output = []
+ while c.memory[c.pointer] != 99:
+ c.step()
+ if c.output != None:
+ output.append(c.output)
+ c.output = None
+ return output
+