Documentation ¶
Index ¶
- Constants
- func Abs(n int) int
- func Board(x, y int) [][]uint
- func Boolean(b bool) int
- func CompleteFuel(mass int) int
- func CritExactlyTwoAdjacent(n int, digits []byte) bool
- func CritIncreasing(n int, digits []byte) bool
- func CritSixDigits(n int, digits []byte) bool
- func CritTwoOrMoreAdjacent(n int, digits []byte) bool
- func CritWithinRange(n int, digits []byte) bool
- func Day10Part2(as []Asteroid, base Asteroid) int
- func Day11Part1(prog IntCode) int
- func Day11Part2(prog IntCode) []byte
- func Day13Part1(cpu IntCodeProcessor, code IntCode) int
- func Day13Part2(cpu IntCodeProcessor, code IntCode) int
- func Day1Part1(lines []string) (int, error)
- func Day1Part2(lines []string) (int, error)
- func Day3Part1(wires []string) (int, error)
- func Day3Part2(wires []string) (int, error)
- func Day4Part1() int
- func Day4Part2() int
- func Day5(program IntCode, input <-chan int, output chan<- int)
- func Day7Part1(prog IntCode, phases string) int
- func Day7Part2(prog IntCode, phases string) int
- func Day8Part1(digits []byte) (int, error)
- func Day8Part2(digits []byte) ([]byte, error)
- func Digits(n int) []byte
- func DigitsInto(n int, buf []byte)
- func False(boolean int) bool
- func Fuel(mass int) int
- func Len(opcodes []int) int
- func MaxSize(wirings []string) (int, int, error)
- func MeetsCriteria(n int, digits []byte, crits []Criteria) bool
- func MinimalDistance(b [][]uint) int
- func Ndigits(n int) int
- func Run(opcodes []int) ([]int, error)
- func Runs(s string) (string, error)
- func Size(wiring string) (int, int, error)
- func Split(s string) ([]int, error)
- func ToString(opcodes []int) string
- func True(boolean int) bool
- func Walk(b [][]uint, wires []string) error
- type Asteroid
- type Criteria
- type Day6
- type Direction
- type IntCode
- type IntCodeProcessor
- type ParameterMode
- type Point
- type RegistrationID
Constants ¶
const ( X = 0 Y = 1 Z = 2 DIMS = 3 MOONS = 4 )
DIMS has three dimensions (x, y, z)
const ( // OpcodeAdd adds parameter OpcodeAdd = 1 // OpcodeMul multiplies parameter OpcodeMul = 2 // OpcodeRet halts the program OpcodeRet = 99 )
const ( // Lower range from puzzle input Lower = 136818 // Upper range from puzzle input Upper = 685979 )
const ( // Input takes a single integer as input and saves it to the position // given by its only parameter. Input = 3 // Output outputs the value of its only parameter. Output = 4 // JumpIfTrue sets the instruction pointer to the value from the second // parameter if the first parameter is non-zero. JumpIfTrue = 5 // JumpIfFalse sets the instruction pointer to the value from the second // parameter if the first parameter is zero. JumpIfFalse = 6 // LessThan stores 1 in the position given by the third parameter if // the first parameter is less than the second parameter, otherwise // it stores 0. LessThan = 7 // Equals stores 1 in the position given by the third parameter if // the first parameter is equal to the second parameter, otherwise // it stores 0. Equals = 8 // AdjustRelBase changes the relative base AdjustRelBase = 9 )
const COM = "COM"
COM is the Center of Mass
Variables ¶
This section is empty.
Functions ¶
func Board ¶
Board creates a two dimensional arrray. The board created will have double width and double height, so that no negative indices are used when wiring.
func CompleteFuel ¶
CompleteFuel computes required fuel for given mass, including fuel for fuel. Both mass and fuel have no units.
func CritExactlyTwoAdjacent ¶
CritExactlyTwoAdjacent two adjacent matching digits are not part of a larger group of matching digits.
func CritIncreasing ¶
CritIncreasing Going from left to right, the digits never decrease; they only ever increase or stay the same (like 111123 or 135679)
func CritSixDigits ¶
CritSixDigits It is a six-digit number
func CritTwoOrMoreAdjacent ¶
CritTwoOrMoreAdjacent Two adjacent digits are the same (like 22 in 122345)
func CritWithinRange ¶
CritWithinRange The value is within the range given in your puzzle input
func Day10Part2 ¶
Day10Part2 determines the 200th asteroid that gets vaporized.
func Day11Part2 ¶
Day11Part2 returns a PBM encoded registration ID. The image is horizontally flipped so em well you can read it from the inside of the transparent hull?
func Day13Part1 ¶
func Day13Part1(cpu IntCodeProcessor, code IntCode) int
Day13Part1 returns number of blocks for arcade game.
func Day13Part2 ¶
func Day13Part2(cpu IntCodeProcessor, code IntCode) int
Day13Part2 returns number of blocks for arcade game.
func Day1Part2 ¶
Day1Part2 returns sum of fuel and transitively the required fuel for the fuel for all modules
func Day4Part1 ¶
func Day4Part1() int
Day4Part1 returns number of passwords between Lower and Upper that meet all criteria
func Day4Part2 ¶
func Day4Part2() int
Day4Part2 returns number of passwords between Lower and Upper that meet all criteria
func Day5 ¶
Day5 supports running IntCode for day 2 (ADD, MUL, RET) and adds input, output, parameter mode and immediate mode.
func Day8Part1 ¶
Day8Part1 returns number of 1s multiplied by number of 2s in the layer having minimal number of 0s.
func Len ¶
Len calculates them maximum index into an array, i.e. the len of an array that can hold opcodes.
func MeetsCriteria ¶
MeetsCriteria returns true if all criteria are fulfilled for n, using short circuit evaluation
func MinimalDistance ¶
MinimalDistance returns minimal manhattan distance of all crossings
func Ndigits ¶
Ndigits returns number of digits that n consists of. 0 has 1 digit, 42 has 2 digits, -4711 has 4 digits. Naming convention taken from Julia
Types ¶
type Asteroid ¶
type Asteroid = complex128
An Asteroid is identified by a dimensionless (x/y) position in a 2D space. Using a type _alias_ here to avoid casting
func Day10Part1 ¶
Day10Part1 returns the asteroid that can see most asteroids, and the number of visible asteroids.
func ParseAsteroidMap ¶
ParseAsteroidMap parses newline separated strings into asteroids.
type Criteria ¶
Criteria is a function that tests an integer. For performance reasons, both numerical and digits are supplied.
func CriteriaPart1 ¶
func CriteriaPart1() []Criteria
CriteriaPart1 returns all required criteria for part 1
func CriteriaPart2 ¶
func CriteriaPart2() []Criteria
CriteriaPart2 returns all required criteria for part 1
type Day6 ¶
type Day6 struct {
// contains filtered or unexported fields
}
Day6 holds an object and its orbit.
func (Day6) CommonOrbit ¶
CommonOrbit returns the nearest orbit of two objects, at least COM.
func (Day6) OrbitCount ¶
OrbitCount returns the number of orbits of a given object.
func (Day6) OrbitCountChecksum ¶
OrbitCountChecksum returns the checksum for a complete orbit.
type IntCode ¶
type IntCode []int
IntCode is both a low-level interpreted language used in bootstrapping the BCPL compiler, and a virtual language in advent of code.
type IntCodeProcessor ¶
IntCodeProcessor can run IntCode
type ParameterMode ¶
type ParameterMode int
ParameterMode is part of the opcode and controls parameter handling
const ( // PositionMode reads memory via index PositionMode ParameterMode = iota // ImmediateMode uses values directly ImmediateMode // RelativeMode addresses via relative base RelativeMode )
type Point ¶
type Point struct {
// contains filtered or unexported fields
}
Point holds a (x/y) position
type RegistrationID ¶
type RegistrationID map[complex128]bool
RegistrationID is a 2D map of black (false) and white (true)