Documentation
¶
Overview ¶
Package intcode implements the AoC 2019 Intcode language.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Reader ¶
type Reader interface {
Read() int64
}
A Reader provides input capabilities to an Intcode computer.
type Solver ¶
Solver wraps a solution that wants an Intcode program in the standard format as input.
type SolverS ¶
SolverS wraps a solution that wants an Intcode program in the standard format as input, outputting arbitrary strings.
type VM ¶
A VM represents the state of an Intcode computer.
func (*VM) Run ¶
Run executes the current program until it halts, reading input from a slice. All output generated by the program will be returned in the output slice.
func (*VM) Walk ¶
Walk executes the current program up to the first halt, input or output instruction. For the initial call, pass in an empty walk token (the zero value). If the function returns false, the computer has halted (and the token will be empty). Otherwise, the computer is requesting either input or output: inspect the walk token to learn which, and to either provide the input or deal with the output, as required. Then call Walk again with the same token to continue operation. This is intended for coöperative multitasking or other complex interleaving of Intcode operation with surrounding logic.
type WalkToken ¶
type WalkToken struct {
// contains filtered or unexported fields
}
WalkToken is used for holding invocation state when running Intcode via the Walk() API.
func (*WalkToken) IsEmpty ¶
IsEmpty returns true if the walk token is empty (requests no input or contains no output).
func (*WalkToken) ProvideInput ¶
ProvideInput is used to set the input on an input-requesting walk token.
func (*WalkToken) ReadOutput ¶
ReadOutput returns the output contained in this output-providing walk token.