day11

package
v0.0.0-...-a30599c Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Canvas

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

Canvas is an infinitely paintable 2D surface.

func NewCanvas

func NewCanvas() *Canvas

NewCanvas creates an empty canvas.

func (*Canvas) At

func (c *Canvas) At(p point.Point2D) int

At gets the color painted at a point.

func (*Canvas) Count

func (c *Canvas) Count() int

Count returns the number of points that have been painted at all.

func (*Canvas) Paint

func (c *Canvas) Paint(p point.Point2D, color int)

Paint paints a point with a color, extending the bounds of the canvas if needed.

func (*Canvas) PrintTo

func (c *Canvas) PrintTo(w io.Writer)

PrintTo prints the image on the canvas to the given writer.

type Direction

type Direction int

Direction is one of the cardinal directions that the robot can move.

const (
	Up Direction = iota
	Down
	Left
	Right
)

The four directions the robot can move.

func (Direction) Advance

func (d Direction) Advance(p *point.Point2D)

Advance moves a point in this direction.

func (*Direction) TurnLeft

func (d *Direction) TurnLeft()

TurnLeft alters the direction to face left from the current direction.

func (*Direction) TurnRight

func (d *Direction) TurnRight()

TurnRight alters the direction to face right from the current direction.

type Robot

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

Robot is an emergency hull painting robot.

func NewRobot

func NewRobot(c *Canvas) *Robot

NewRobot creates a new robot that paints on the given canvas.

func (*Robot) CurrentColor

func (r *Robot) CurrentColor() int

CurrentColor returns the color of the canvas at the robot's current location.

func (*Robot) Run

func (r *Robot) Run(output chan int)

Run runs the robot according to the instructions from output.

Jump to

Keyboard shortcuts

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