From 0c83aadcf938f505a32b2082d8815a62de22c4b4 Mon Sep 17 00:00:00 2001 From: flifloo Date: Mon, 2 Dec 2019 08:18:44 +0100 Subject: [PATCH] Day 2 P1 --- 2019/day 2/P1/computer.py | 14 ++++++++++++++ 2019/day 2/P1/input.txt | 1 + 2 files changed, 15 insertions(+) create mode 100644 2019/day 2/P1/computer.py create mode 100644 2019/day 2/P1/input.txt diff --git a/2019/day 2/P1/computer.py b/2019/day 2/P1/computer.py new file mode 100644 index 0000000..4e3f10a --- /dev/null +++ b/2019/day 2/P1/computer.py @@ -0,0 +1,14 @@ +codes = open("input.txt").read().split(",") +codes = [int(i) for i in codes] + +codes[1] = 12 +codes[2] = 2 + +i=0 +while i < len(codes) and codes[i] != 99: + if codes[i] == 1: + codes[codes[i+3]] = codes[codes[i+1]] + codes[codes[i+2]] + elif codes[i] == 2: + codes[codes[i+3]] = codes[codes[i+1]] * codes[codes[i+2]] + i+=4 +print(codes[0]) diff --git a/2019/day 2/P1/input.txt b/2019/day 2/P1/input.txt new file mode 100644 index 0000000..835f660 --- /dev/null +++ b/2019/day 2/P1/input.txt @@ -0,0 +1 @@ +1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,13,1,19,1,19,10,23,2,10,23,27,1,27,6,31,1,13,31,35,1,13,35,39,1,39,10,43,2,43,13,47,1,47,9,51,2,51,13,55,1,5,55,59,2,59,9,63,1,13,63,67,2,13,67,71,1,71,5,75,2,75,13,79,1,79,6,83,1,83,5,87,2,87,6,91,1,5,91,95,1,95,13,99,2,99,6,103,1,5,103,107,1,107,9,111,2,6,111,115,1,5,115,119,1,119,2,123,1,6,123,0,99,2,14,0,0