Deprecate nouns and verbs arguments for intcode

This commit is contained in:
Anders Englöf Ytterström 2023-12-14 22:46:15 +01:00
parent f98545ae5a
commit 5cb2dccf62
2 changed files with 14 additions and 10 deletions

View file

@ -1,5 +1,4 @@
from output import answer, puzzleinput
from collections import defaultdict
from output.intcode_computer import execute, parse
@ -14,13 +13,17 @@ def parse_input(data):
@answer(1, "[intcode-0.1.0] Value of pos 0 is {} at halt signal")
def part_1(program):
_code, state, *_unused = execute(program, noun=12, verb=2)
program[1] = 12
program[2] = 2
_code, state, *_unused = execute(program)
return state[0]
@answer(2, "[intcode-0.1.1] 100 * noun + verb = {} for output 19690720")
def part_2(program, noun=76, verb=21):
_code, state, *_unused = execute(program, noun, verb)
program[1] = noun
program[2] = verb
_code, state, *_unused = execute(program)
if state[0] == 19690720:
return 100 * noun + verb
return state[0]

View file

@ -7,6 +7,13 @@ intcode computer, AoC 2019
Changelog
=========
0.3.3
-----
Patch release (no specific day)
- Deprecating noun and verb. Those are now up to consumer to provide.
0.3.2
-----
@ -80,7 +87,7 @@ Initial version (day 2 part 1).
- Add operation 1: adds parameter 1 to parameter 2, store to parameter 3 position
- Add operation 2: multiply parameter 1 with parameter 2, store to parameter 3 position
"""
__version__ = "0.3.2"
__version__ = "0.3.3"
def parse(data):
@ -89,8 +96,6 @@ def parse(data):
def execute(
program,
noun=None,
verb=None,
stdin=[],
debug=False,
interactive=False,
@ -109,10 +114,6 @@ def execute(
state[k] = v
else:
state = program.copy()
if noun:
state[1] = noun
if verb:
state[2] = verb
stdout = []
def halt(code):