day07_2019

package
v0.0.0-...-359cf57 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package day07_2019 contains the solver for Advent of Code - Day 7: Amplification Circuit

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunPermutation

func RunPermutation(permutation []int, memory intcode.Memory) int

func RunPermutationWithFeedback

func RunPermutationWithFeedback(permutation []int, memory intcode.Memory) int

Types

type MaxIntPipe

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

MaxIntPipe represents a pipe of integers that also remembers the last value written to it

func NewMaxIntPipe

func NewMaxIntPipe() MaxIntPipe

NewMaxIntPipe creates and initializes a new MaxIntPipe

func (*MaxIntPipe) Close

func (p *MaxIntPipe) Close()

Close closes the pipe

func (*MaxIntPipe) Max

func (p *MaxIntPipe) Max() int

Max returns the max value written on this pipe

func (*MaxIntPipe) ReadInt

func (p *MaxIntPipe) ReadInt() int

ReadInt reads an int from the pipe. Implements the IntReader interface

func (*MaxIntPipe) WriteInt

func (p *MaxIntPipe) WriteInt(i int)

WriteInt writes an int to the pipe. Implements the IntWriter interface.

type MaxWriter

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

MaxWriter is a IntWriter that only keeps the maximum value written to it

func NewMaxWriter

func NewMaxWriter() MaxWriter

NewMaxWriter returns a new max writer

func (*MaxWriter) Max

func (mw *MaxWriter) Max() int

Max gets the maximum value written to this writer

func (*MaxWriter) WriteInt

func (mw *MaxWriter) WriteInt(value int)

WriteInt writes an int to this writer. Implements the IntWriter interface.

type Solver

type Solver struct {
	intcode.Memory
}

Solver implements the puzzle.Solver interface for the puzzle for day 7

func NewSolver

func NewSolver() *Solver

NewSolver returns a new solver

func (*Solver) Part1

func (s *Solver) Part1() (string, error)

Part1 solves part 1 of the puzzle. Required to implement Solver.

func (*Solver) Part2

func (s *Solver) Part2() (string, error)

Part2 solves part 2 of the puzzle. Required to implement Solver.

func (*Solver) ProcessInput

func (s *Solver) ProcessInput(fileContent string) error

ProcessInput processes the input. Required to implement Solver.

Jump to

Keyboard shortcuts

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