exercises

package
v0.0.0-...-e61498d Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: Unlicense Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Cycle20  int = 20
	Cycle60  int = 60
	Cycle100 int = 100
	Cycle140 int = 140
	Cycle180 int = 180
	Cycle220 int = 220
)

Cycle constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Instruction Instruction
	Value       int
}

Command is a single instruction with a value.

type Day10

type Day10 struct {
	Cycle    int
	X        map[int]int
	Commands []Command
	Cycle20  int
	Cycle60  int
	Cycle100 int
	Cycle140 int
	Cycle180 int
	Cycle220 int
}

Day10 is the exercise environment.

func (*Day10) Calculate

func (d *Day10) Calculate() int

Calculate returns the result of the processing.

func (*Day10) Draw

func (d *Day10) Draw() string

Draw returns a string showing which pixels are lit.

func (*Day10) Parse

func (d *Day10) Parse(data []string) error

Parse converts the input data into a tokenized form.

func (*Day10) Process

func (d *Day10) Process() error

Process executes the commands.

type Exercise

type Exercise struct {
	common.BaseExercise
}

Exercise for Advent of Code 2022 day 10.

func (Exercise) One

func (c Exercise) One(instr string) (any, error)

One returns the answer to the first part of the exercise. answer: 17380

func (Exercise) Two

func (c Exercise) Two(instr string) (any, error)

Two returns the answer to the second part of the exercise. answer: FGCUZREC

type Instruction

type Instruction string

Instruction is string type for instructions.

const (
	Add  Instruction = "addx"
	Noop Instruction = "noop"
)

Instruction constants.

Jump to

Keyboard shortcuts

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