lib

package
v0.0.0-...-df6d6b4 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(a int) int

Abs returns the absolute value of a.

func ForLines

func ForLines(filename string, f func(str string))

ForLines calls f for each line in a file.

func Gcd

func Gcd(a, b int) int

Gcd computes the greatest common divisor of a and b.

func IntEq

func IntEq(a, b []int) bool

IntEq compares two int slices.

func Lcm

func Lcm(as ...int) int

Lcm computes the lowest common multiple of a set of integers.

func Load

func Load(filename string) string

Load loads a file.

func StrEq

func StrEq(a, b []string) bool

StrEq compares two string slices.

Types

type ASCIIPuter

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

An ASCIIPuter makes it easy to do ASCII input to and output from a Puter.

func ASCIIfy

func ASCIIfy(p *Puter) *ASCIIPuter

ASCIIfy wraps a Puter in an ASCIIPuter.

func (*ASCIIPuter) Exec

func (a *ASCIIPuter) Exec(input string) string

Exec executes the given command and returns its output.

func (*ASCIIPuter) Input

func (a *ASCIIPuter) Input(in string)

Input feeds some ASCII input to the Puter.

func (*ASCIIPuter) Output

func (a *ASCIIPuter) Output() string

Output returns the current ASCII-interpreted output of the Puter.

func (*ASCIIPuter) Result

func (a *ASCIIPuter) Result() int

Result returns the non-ascii result.

func (*ASCIIPuter) Run

func (a *ASCIIPuter) Run() bool

Run runs the puter until it wants more input.

type Program

type Program []int

A Program written in Intcode.

func LoadProgram

func LoadProgram(filename string) Program

LoadProgram loads an intcode program from a file.

type Puter

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

A Puter is an intcode computer.

func NewPuter

func NewPuter(prog Program) *Puter

NewPuter creates a new Puter.

func (*Puter) DropStdout

func (p *Puter) DropStdout()

DropStdout drops any buffered stdout

func (*Puter) Read

func (p *Puter) Read(n int) int

Read reads a value from memory.

func (*Puter) Run

func (p *Puter) Run()

Run runs the intcode program until it quits.

func (*Puter) RunNB

func (p *Puter) RunNB() bool

RunNB runs the intcode program until it either quits or needs more input.

func (*Puter) Stdin

func (p *Puter) Stdin(stdin []int)

Stdin sets the computer's input stream.

func (*Puter) StdinCh

func (p *Puter) StdinCh(ch <-chan int)

StdinCh sets the computer's input stream as a channel.

func (*Puter) Stdout

func (p *Puter) Stdout() []int

Stdout returns the computer's output stream.

func (*Puter) StdoutCh

func (p *Puter) StdoutCh(ch chan<- int)

StdoutCh sets this puter's stdout channel.

func (*Puter) Write

func (p *Puter) Write(n, val int)

Write writes a value into memory.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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