diff options
| author | Gustav Sörnäs <gusso230@student.liu.se> | 2019-12-04 07:02:31 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gusso230@student.liu.se> | 2019-12-04 07:02:31 +0100 |
| commit | 831755fdc6d430bd8781da1897270cf2934bc858 (patch) | |
| tree | f1d6e5609363f98534a87eb9203a7623fb409371 /solutions/py/02-1.py | |
| download | aoc-831755fdc6d430bd8781da1897270cf2934bc858.tar.gz | |
Initial commit
Diffstat (limited to 'solutions/py/02-1.py')
| -rw-r--r-- | solutions/py/02-1.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/solutions/py/02-1.py b/solutions/py/02-1.py new file mode 100644 index 0000000..47ab15f --- /dev/null +++ b/solutions/py/02-1.py @@ -0,0 +1,19 @@ +import sys + +program = [int(x) for x in input().split(",")] + +memory = program.copy() +memory[1] = 12 +memory[2] = 2 + +pointer = 0 +while True: + if memory[pointer] == 99: + break + elif memory[pointer] == 1: + memory[memory[pointer+3]] = memory[memory[pointer+1]] + memory[memory[pointer+2]] + elif memory[pointer] == 2: + memory[memory[pointer+3]] = memory[memory[pointer+1]] * memory[memory[pointer+2]] + pointer += 4 +print(memory[0]) + |
