Documentation
¶
Index ¶
- Variables
- func Day00(s Puzzle, part1 bool) (uint, error)
- func Day01Part1(digits []byte) (sum uint)
- func Day01Part2(digits []byte) (sum uint)
- func Day02Part1(spreadsheet [][]int) (sum uint)
- func Day02Part2(spreadsheet [][]int) (sum uint)
- func Day03Part1(square int) int
- func Day03Part2(n uint) uint
- func Day04Part1(passphrases []string) (count uint)
- func Day04Part2(passphrases []string) (count uint)
- func Day04Part2Valid(passphrase string) bool
- func Day05Part1(maze []int) int
- func Day05Part2(maze []int) int
- func Day06Part1(banks Banks, activeBanks int) int
- func Day06Part2(banks Banks, activeBanks int) int
- func Day07Part1(ss []string) string
- func Day07Part2(ss []string) (uint, error)
- func Day08Part1(data []byte) (int, error)
- func Day08Part2(data []byte) (int, error)
- func Day09Part1(stream []byte) int
- func Day09Part2(stream []byte) int
- func Day10(list []int, lengths []int) int
- func Day10PreconditionLength(list []int, lengths []int) ([]int, error)
- func Day10Reverse(list []int, idx int, n int)
- func Day12(r io.Reader) int
- func Day13UsingList(l *node) int
- func Day13UsingSparseArray(layers []int) int
- func NewProgram(s string) (program, error)
- type Banks
- type Cmp
- type Condition
- type Disk
- type Instruction
- type Operation
- type Puzzle
- type RA
- type Registers
Constants ¶
This section is empty.
Variables ¶
var A141481 = []uint{}/* 479 elements not displayed */
A141481 Square spiral of sums of selected preceding terms, starting at 1. Table of a(n) for n = 0..478 (largest possible uint64) Source: https://oeis.org/A141481/b141481.txt
var ErrorDay10Length = fmt.Errorf("illegal length")
Functions ¶
func Day00 ¶ added in v0.9.1
Day00 solves the puzzle for day NN, and provides a result. The name `Day00` MUST be adjusted to `Day{{NN}}` for the given day NN. The identifier for day NN MUST be two digits even for single digit days (`Day07` not `Day7`). The name MUST NOT be changed to the puzzle name (`NotQuiteLisp`). The priority for implementations is maximum performance in runtime, and minimal garbage collection. Common practices for maintainability, ease of reading, clean code, are NOT REQUIRED. Implementations SHOULD use high performance parser using puzzle input as []byte and leave out the corresponding parser `NewPuzzle`. Implementations SHOULD limit the result types to `uint` (counts, sums), `string` (text) and `int` (solutions that include negative numbers, which is very rare).
func Day01Part1 ¶ added in v0.9.1
Day01Part1 finds the sum of all digits that match the next digit.
func Day01Part2 ¶ added in v0.9.1
Day01Part2 finds the sum of all digits that match the halfway around digit.
func Day02Part1 ¶ added in v0.9.1
Day02Part1 calculates the spreadsheet's checksum for smallest and largest cells.
func Day02Part2 ¶ added in v0.9.1
Day02Part2 calculates checksum for evenly divisible cells.
func Day03Part1 ¶ added in v0.9.1
Day03Part1 returns the number of steps for a given square. 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 Day03Part2 ¶ added in v0.9.1
Day03Part2 returns the first number larger than n of https://oeis.org/A141481.
func Day04Part1 ¶ added in v0.9.1
Day04 returns the number of valid pass phrases. valid := contains no duplicate words, separated by space
func Day04Part2 ¶ added in v0.9.1
func Day04Part2Valid ¶ added in v0.9.1
func Day05Part1 ¶
Day05Part1 returns the number of steps until outside of maze.
func Day05Part2 ¶
Day05Part2 returns the number of steps until outside of maze.
func Day06Part1 ¶ added in v0.9.1
Day06Part1 returns number of redistribution cycles.
func Day06Part2 ¶ added in v0.9.1
Day06Part2 returns number of redistribution cycles for a configuration already seen.
func Day07Part1 ¶ added in v0.9.1
func Day07Part2 ¶ added in v0.9.1
Day07Part2 returns the excess weight to balance the complete tower.
func Day08Part1 ¶ added in v0.9.1
func Day08Part2 ¶ added in v0.9.1
Day08Part2 returns the highest value held in any register at any time during processing of the instructions.
func Day09Part1 ¶ added in v0.9.1
func Day09Part2 ¶ added in v0.9.1
Day09Part2 counts the number of non-canceled characters within garbage. The opening '<' and closing '>' are not counted. Canceled characters and the '!' doing the canceling are not counted either.
func Day10PreconditionLength ¶
spec states "Lengths larger than the size of the list are invalid." which is a bit unclear as to wether this can occur in input or not. We opt for the safe side which makes it a precondition. Day10PreconditionLength checks if all length parameters are in list bounds. Returns a list of illegal length indices.
func Day10Reverse ¶
Day10Reverse in-place reverse slice list[idx:idx+n], wrapping n if n > len(list)
func Day13UsingList ¶
func Day13UsingList(l *node) int
Day13UsingList returns severity of whole trip through layers.
func Day13UsingSparseArray ¶
Day13UsingSparseArray returns severity of whole trip through layers.
func NewProgram ¶ added in v0.9.1
NewProgram parses a string representation into a domain model. Examples: ktlj (57) fwft (72) -> ktlj, cntj, xhth
Types ¶
type Instruction ¶
type Puzzle ¶ added in v0.9.1
type Puzzle struct { }
Puzzle acts as a generic name, implementations MUST adjust to concrete puzzle. All puzzles have a unique name that MUST be used instead of `Puzzle`, e.g. `NotQuiteLisp', the first puzzle ever (Day 1, 2015).
func NewPuzzle ¶ added in v0.9.1
NewPuzzle parses the puzzle input in text form into an efficient representation for day N. The parser function CAN be left out if the solver (`Day00`) is implemented using puzzle input []byte for maximum performance. Implementations CAN use puzzle input as []byte instead of []string for best performance, or if problem solution is grid based instead of line based.. When using []byte input, parser CAN rely on input in format end_of_line = lf, insert_final_newline = true, trim_trailing_whitespace = true. Parser DO NOT HAVE TO cater for malicious input, but use regular error handling e.g. when parsing numbers using strconv.Atoi(). Parser MUST NOT suppress or ignore errors.