intcode

package
v0.0.0-...-07010e4 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Add           int = 1
	Mult          int = 2
	Input         int = 3
	Output        int = 4
	JmpIfTrue     int = 5
	JmpIfFalse    int = 6
	Less          int = 7
	Equal         int = 8
	RelBaseOffset int = 9
	Halt          int = 99
)

Variables

This section is empty.

Functions

func Exec

func Exec(in []int) ([]int, error)

func Exec2

func Exec2(prg []int, inputs []int) (modin []int, output []int, err error)

func ExecC

func ExecC(prg []int, inC chan int, outC chan int)

Types

type Computer

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

func NewComputer

func NewComputer(prg []int, inputReader IntReader, outputWriter IntWriter) *Computer

func (*Computer) Exec

func (com *Computer) Exec() error

type IntChannelReader

type IntChannelReader struct {
	C chan int
}

func NewIntChannelReader

func NewIntChannelReader(buffer int) *IntChannelReader

func (*IntChannelReader) Close

func (r *IntChannelReader) Close()

func (*IntChannelReader) Provide

func (r *IntChannelReader) Provide(n int)

func (*IntChannelReader) Read

func (r *IntChannelReader) Read() (int, error)

type IntChannelWriter

type IntChannelWriter struct {
	C chan int
}

func NewIntChannelWriter

func NewIntChannelWriter(buffer int) *IntChannelWriter

func (*IntChannelWriter) Close

func (r *IntChannelWriter) Close()

func (*IntChannelWriter) Get

func (w *IntChannelWriter) Get() (int, bool)

func (*IntChannelWriter) Write

func (w *IntChannelWriter) Write(v int) error

type IntReader

type IntReader interface {
	Read() (int, error)
}

type IntSliceReader

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

func NewIntSliceReader

func NewIntSliceReader(values []int) *IntSliceReader

func (*IntSliceReader) Read

func (r *IntSliceReader) Read() (int, error)

type IntSliceWriter

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

func NewIntSliceWriter

func NewIntSliceWriter() *IntSliceWriter

func (*IntSliceWriter) Values

func (w *IntSliceWriter) Values() []int

func (*IntSliceWriter) Write

func (w *IntSliceWriter) Write(v int) error

type IntWriter

type IntWriter interface {
	Write(int) error
}

type NonBlockingIntChannelReader

type NonBlockingIntChannelReader struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewNonBlockingIntChannelReader

func NewNonBlockingIntChannelReader(emptyValue int) *NonBlockingIntChannelReader

func (*NonBlockingIntChannelReader) Close

func (r *NonBlockingIntChannelReader) Close()

func (*NonBlockingIntChannelReader) Provide

func (r *NonBlockingIntChannelReader) Provide(ns ...int)

func (*NonBlockingIntChannelReader) Read

func (r *NonBlockingIntChannelReader) Read() (int, error)

type NonBlockingIntChannelWriter

type NonBlockingIntChannelWriter struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewNonBlockingIntChannelWriter

func NewNonBlockingIntChannelWriter() *NonBlockingIntChannelWriter

func (*NonBlockingIntChannelWriter) Read

func (r *NonBlockingIntChannelWriter) Read(cnt int) ([]int, bool)

func (*NonBlockingIntChannelWriter) Write

type SignallingIntChannelReader

type SignallingIntChannelReader struct {
	C     chan int
	WantC chan bool
}

func NewSignallingIntChannelReader

func NewSignallingIntChannelReader(buffer int) *SignallingIntChannelReader

func (*SignallingIntChannelReader) Close

func (r *SignallingIntChannelReader) Close()

func (*SignallingIntChannelReader) Provide

func (r *SignallingIntChannelReader) Provide(n int)

func (*SignallingIntChannelReader) Read

func (r *SignallingIntChannelReader) Read() (int, error)

Jump to

Keyboard shortcuts

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