Deprecate nouns and verbs arguments for intcode
This commit is contained in:
parent
f98545ae5a
commit
5cb2dccf62
2 changed files with 14 additions and 10 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
from output import answer, puzzleinput
|
from output import answer, puzzleinput
|
||||||
from collections import defaultdict
|
|
||||||
|
|
||||||
from output.intcode_computer import execute, parse
|
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")
|
@answer(1, "[intcode-0.1.0] Value of pos 0 is {} at halt signal")
|
||||||
def part_1(program):
|
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]
|
return state[0]
|
||||||
|
|
||||||
|
|
||||||
@answer(2, "[intcode-0.1.1] 100 * noun + verb = {} for output 19690720")
|
@answer(2, "[intcode-0.1.1] 100 * noun + verb = {} for output 19690720")
|
||||||
def part_2(program, noun=76, verb=21):
|
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:
|
if state[0] == 19690720:
|
||||||
return 100 * noun + verb
|
return 100 * noun + verb
|
||||||
return state[0]
|
return state[0]
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,13 @@ intcode computer, AoC 2019
|
||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
0.3.3
|
||||||
|
-----
|
||||||
|
|
||||||
|
Patch release (no specific day)
|
||||||
|
|
||||||
|
- Deprecating noun and verb. Those are now up to consumer to provide.
|
||||||
|
|
||||||
0.3.2
|
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 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
|
- 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):
|
def parse(data):
|
||||||
|
|
@ -89,8 +96,6 @@ def parse(data):
|
||||||
|
|
||||||
def execute(
|
def execute(
|
||||||
program,
|
program,
|
||||||
noun=None,
|
|
||||||
verb=None,
|
|
||||||
stdin=[],
|
stdin=[],
|
||||||
debug=False,
|
debug=False,
|
||||||
interactive=False,
|
interactive=False,
|
||||||
|
|
@ -109,10 +114,6 @@ def execute(
|
||||||
state[k] = v
|
state[k] = v
|
||||||
else:
|
else:
|
||||||
state = program.copy()
|
state = program.copy()
|
||||||
if noun:
|
|
||||||
state[1] = noun
|
|
||||||
if verb:
|
|
||||||
state[2] = verb
|
|
||||||
stdout = []
|
stdout = []
|
||||||
|
|
||||||
def halt(code):
|
def halt(code):
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue