intcode

package
v0.0.0-...-68053d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(program []int64) []int64

Copy will copy an intcode program.

func FromAscii

func FromAscii(s string) []int64

FromAscii converts a string to a slice of int64s.

func ParseProgram

func ParseProgram(commaString string) ([]int64, error)

ParseProgram parses an intcode program to a slice of ints.

func ReadProgram

func ReadProgram(filename string) ([]int64, error)

ReadProgram reads a file with a single intCode program.

func RunProgram

func RunProgram(originalState []int64, reads []int64, debug bool) (state []int64, writes []int64, err error)

RunProgram runs an intcode program, modifying the state in place, and using slices for reads and writes.

func RunProgramChans

func RunProgramChans(ctx context.Context, originalState []int64, reads <-chan int64, writes chan<- int64, errs chan<- error, updates <-chan [2]int64, debug bool, debugPrefix string)

RunProgramChans runs an intcode program, modifying the state in place, and using channels for input and output.

func ToAscii

func ToAscii(ints []int64) string

ToAscii converts a slice of int64s to a string.

Types

type OpDef

type OpDef struct {
	// contains filtered or unexported fields
}

OpDef defines a single opcode.

func (OpDef) Show

func (op OpDef) Show(source []int64) (string, error)

Show displays the given OpCode with the given arguments.

type OpFunc

type OpFunc func(pc int, inputs []int64, reads []int64) (newPc int, baseAdj int64, outputs []int64, writes []int64, err error)

OpFunc is the function type for running an opcode.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL