adventofcode2017

package module
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2018 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(n int) int

Abs returns the absolute value of an integer

func Day1

func Day1(digits []byte) int

Day1 finds the sum of all digits that match the next digit

func Day12

func Day12(r io.Reader) int

Day12 returns number of programs being in the group that contains program ID 0.

func Day2

func Day2(spreadsheet [][]int) int

func Day3

func Day3(square int) int

Day3 returns the number of steps for a given square to square 1. A recursive implementation is used that produces a stack overflow for values around 1e8. The recursive call can be replaced by a loop based impl using Delta() only.

func Day4

func Day4(passphrases []string) int

Day4 returns the number of valid pass phrases valid := contains no duplicate words, separated by space

func Day5Part1

func Day5Part1(maze []int) int

Day5 returns the number of steps until outside of maze.

func Day5Part2

func Day5Part2(maze []int) int

Day5 returns the number of steps until outside of maze.

func Day6Impl1

func Day6Impl1(banks Banks, activeBanks int) int

Day6 returns number of redistributions.

func Day6Impl2

func Day6Impl2(banks []int) int

func Day7

func Day7(r io.Reader) string

func Day8

func Day8(r io.Reader) (int, error)

func Day9

func Day9(stream []byte) int

Day9 is O(n) and allocation free (0 B/op).

func Delta

func Delta(n int, axisfn func(float64) float64) int

Delta returns transformation for one single square

func Transform

func Transform(n int, axisfn func(float64) float64, clockwise bool) int

Helper will project a point on a spiral into either X or Y coordinates for both clockwise and counterclockwise spirals. projecting a spiral onto X and Y involves (co-)sine, and oeis has appropriate formulas (as always).

A174344 lists x-coordinates of point moving in clockwise spiral. https://oeis.org/A174344 A268038 lists y-coordinates of point moving in clockwise spiral. https://oeis.org/A268038

func X

func X(n int) int

func Y

func Y(n int) int

Types

type Banks

type Banks [16]int

type Cmp

type Cmp int
const (
	EQ Cmp = iota
	NE
	LT
	LE
	GT
	GE
)

type Condition

type Condition struct {
	RA
	// contains filtered or unexported fields
}

type Instruction

type Instruction struct {
	Operation
	Condition
}

type Operation

type Operation struct {
	RA
	// contains filtered or unexported fields
}

type RA

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

type Registers

type Registers map[string]int

func (Registers) Apply

func (a Registers) Apply(op Operation)

func (Registers) Dump

func (a Registers) Dump()

func (Registers) Max

func (a Registers) Max() int

func (Registers) Step

func (a Registers) Step(i Instruction)

func (Registers) True

func (a Registers) True(c Condition) bool

Jump to

Keyboard shortcuts

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