intcode

package
v0.0.0-...-4d3da1a Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DebugNone = DebugMode(iota)
	DebugInfo
	DebugVerbose
)
View Source
const (
	NOP = iota
	ADD
	MUL
	IN
	OUT
	NON_ZERO
	ZERO
	LT
	EQ
	REL

	EOF = 99
)
View Source
const (
	ModePosition = ParameterMode(iota)
	ModeImmediate
	ModeRelative
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DebugMode

type DebugMode int

type IntCode

type IntCode struct {
	Name                     string
	Memory                   map[int]int
	Cursor                   int
	IgnoreNonAddressedMemory bool
	DebugMode                DebugMode
	Input                    ReadWriter
	Output                   ReadWriter
	OutputLinkedFromInput    bool
	Done                     chan bool

	RelativeOffset int
	// contains filtered or unexported fields
}

func New

func New(puzzle string, cursorStart int, seq ...int) *IntCode

New copy the intcode memory before creating a new IntCode object.

func (*IntCode) Address

func (c *IntCode) Address(addr int) int

Address reads the address value at position addr.

func (*IntCode) IntCodeToIntCodeProtocol

func (c *IntCode) IntCodeToIntCodeProtocol(inputC chan int)

func (*IntCode) Read

func (c *IntCode) Read(offset int) int

func (*IntCode) ReadInput

func (c *IntCode) ReadInput() int

func (*IntCode) Run

func (c *IntCode) Run() int

Run the IntCode program.

func (*IntCode) RunBackground

func (c *IntCode) RunBackground()

RunBackground runs in a go func.

func (*IntCode) SetAddress

func (c *IntCode) SetAddress(addr, value int)

SetAddress sets the given value into the address addr.

func (*IntCode) SetIf

func (c *IntCode) SetIf(offset int, cond bool)

func (*IntCode) SetValue

func (c *IntCode) SetValue(addr, value int)

SetValue sets the given value into the address value at position addr.

func (*IntCode) String

func (c *IntCode) String() string

func (*IntCode) Value

func (c *IntCode) Value(addr int) int

Value reads the immediate value at address addr.

func (*IntCode) Write

func (c *IntCode) Write(offset, value int)

func (*IntCode) WriteOutput

func (c *IntCode) WriteOutput(out int)

type ParameterMode

type ParameterMode int

type ReadWriter

type ReadWriter struct {
	C    chan int
	Buff []int
}

ReadeWriter chan (C) expects a request and a response.

Jump to

Keyboard shortcuts

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