adventofcode2022

package
v0.0.0-...-e1661be Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ROOT_DIR = "/"
	GO_UP    = ".."
)
View Source
const (
	MAX_SIZE                = 70000000
	MIN_EXPECTED_FREE_SPACE = 30000000
)
View Source
const LS_OUTPUT_DIR_PREFIX = "dir"

Variables

View Source
var (
	Hlineb    = []int{15 << 1}
	Vlineb    = []int{1 << 4, 1 << 4, 1 << 4, 1 << 4}
	Xb        = []int{2 << 2, 7 << 2, 2 << 2}
	Reverselb = []int{1 << 2, 1 << 2, 7 << 2}
	Squareb   = []int{3 << 3, 3 << 3}
)

Functions

func Abs

func Abs(arg int) int

func Addition

func Addition(arg1 int, arg2 int) int

func Max

func Max(arg1 int, arg2 int) int

func Min

func Min(arg1 int, arg2 int) int

func Min64

func Min64(arg1 int64, arg2 int64) int64

func Multiplaction

func Multiplaction(arg1 int, arg2 int) int

func Swap

func Swap(arg1 *int, arg2 *int)

func Task10_1

func Task10_1(ir InputReader, cnvrtInpt func(InputReader) ([]StatefullCmd, error), debug bool) (string, error)

func Task10_2

func Task10_2(ir InputReader, cnvrtInpt func(InputReader) ([]StatefullCmd, error), debug bool) (string, error)

func Task11_1

func Task11_1(ir InputReader, cnvrtInpt func(InputReader) (Monkeys, error), debug bool) (string, error)

func Task11_2

func Task11_2(ir InputReader, cnvrtInpt func(InputReader) (Monkeys, error), debug bool) (string, error)

func Task12_1

func Task12_1(ir InputReader, cnvrtInpt func(ir InputReader) (ElevationMap, error), debug bool) (string, error)

func Task12_1V

func Task12_1V(ir InputReader, cnvrtInpt func(InputReader) (ElevationMap, error))

func Task12_2

func Task12_2(ir InputReader, cnvrtInpt func(ir InputReader) (ElevationMap, error), debug bool) (string, error)

func Task13_1

func Task13_1(ir InputReader, cnvrtInpt func(InputReader) ([]TupleString, error), debug bool) (string, error)

func Task13_2

func Task13_2(ir InputReader, cnvrtInpt func(InputReader) ([]TupleString, error), debug bool) (string, error)

func Task14_1

func Task14_1(ir InputReader, cnvrtInpt func(InputReader) (Cave, error), debug bool) (string, error)

func Task14_2

func Task14_2(ir InputReader, cnvrtInpt func(InputReader) (Cave, error), debug bool) (string, error)

func Task14_2V

func Task14_2V(ir InputReader, cnvrtInpt func(InputReader) (Cave, error))

func Task15_1

func Task15_1(ir InputReader, cnvrtInpt func(InputReader) (SensorsBeaconsField, error), debug bool) (string, error)

func Task15_2

func Task15_2(ir InputReader, cnvrtInpt func(InputReader) (SensorsBeaconsField, error), debug bool) (string, error)

func Task16_1

func Task16_1(ir InputReader, cnvrtInpt func(InputReader) (Day16Inpt, error), debug bool) (string, error)

func Task16_2

func Task16_2(ir InputReader, cnvrtInpt func(InputReader) (Day16Inpt, error), debug bool) (string, error)

func Task17_1

func Task17_1(ir InputReader, cnvrtInpt func(InputReader) ([]Direction, error), debug bool) (string, error)

This approach can't handle number of iteration needed for 2nd part, possibly need to find repeatable pattern

func Task18_1

func Task18_1(ir InputReader, cnvrtInp func(InputReader) ([]Point3D, error), debug bool) (string, error)

func Task1_1

func Task1_1(ir InputReader, convertInput func(ir InputReader) ([]IntOrSpace, error)) (string, error)

func Task1_2

func Task1_2(ir InputReader, convertInput func(ir InputReader) ([]IntOrSpace, error)) (string, error)

func Task2_1

func Task2_1(ir InputReader, convertInput func(ir InputReader) ([]TupleRPS, error)) (string, error)

Standard rules

func Task2_2

func Task2_2(ir InputReader, convertInput func(ir InputReader) ([]TupleRPS, error)) (string, error)

func Task3_1

func Task3_1(ir InputReader, convertInput func(ir InputReader) ([]TupleIntArr, error)) (string, error)

Solution in this task is only for group of two sequences of items General solution can be found in Task3_2

func Task3_2

func Task3_2(ir InputReader, convertInput func(ir InputReader, groups int) ([][][]int, error)) (string, error)

data structure is follwing:

[][][]int is: groups[

backpups_in_group[
	items_in_backpack[
		item_value
		]
	]
]

]

func Task4_1

func Task4_1(ir InputReader, convInput func(InputReader) ([]TupleSegment, error)) (string, error)

func Task4_2

func Task4_2(ir InputReader, convInput func(InputReader) ([]TupleSegment, error)) (string, error)

func Task5_1

func Task5_1(ir InputReader, cnvrtInpt func(InputReader) (Stacks, Moves, error)) (string, error)

func Task5_2

func Task5_2(ir InputReader, cnvrtInpt func(InputReader) (Stacks, Moves, error)) (string, error)

func Task6_1

func Task6_1(ir InputReader, cnvrtInpt func(InputReader) (string, error)) (string, error)

func Task6_2

func Task6_2(ir InputReader, cnvrtInpt func(InputReader) (string, error)) (string, error)

func Task7_1

func Task7_1(ir InputReader, cnvrInpt func(InputReader) (CommandQueue, error)) (string, error)

func Task7_2

func Task7_2(ir InputReader, cnvrInpt func(InputReader) (CommandQueue, error)) (string, error)

func Task8_1

func Task8_1(ir InputReader, cnvrtInpt func(ir InputReader) ([][]TreeInfo, error), debug bool) (string, error)

func Task8_2

func Task8_2(ir InputReader, cnvrtInpt func(ir InputReader) ([][]TreeInfo, error), debug bool) (string, error)

func Task9_1

func Task9_1(ir InputReader, cnvrtInpt func(InputReader) ([]KnotMove, error), debug bool) (string, error)

func Task9_2

func Task9_2(ir InputReader, cnvrtInpt func(InputReader) ([]KnotMove, error), debug bool) (string, error)

func To2DTreeInfoArray

func To2DTreeInfoArray(ir InputReader) ([][]TreeInfo, error)

func To3DArray

func To3DArray(ir InputReader, groups int) ([][][]int, error)

func ToSingleLine

func ToSingleLine(ir InputReader) (string, error)

func ToStacksAndMoves

func ToStacksAndMoves(ir InputReader) (Stacks, Moves, error)

Types

type Addx

type Addx struct {
	Cycle int
	Arg   int
}

func NewAddxCmd

func NewAddxCmd(arg int) Addx

func (Addx) Execute

func (c Addx) Execute(s *CmdState, needSave func(cycle int, state int) bool, save func(cycle int, state int) int)

type Cave

type Cave struct {
	Rocks map[Point]byte
	MinX  int
	MaxX  int
	// lowest point
	MaxY int
	//highest point
	MinY int
}

func ToRockMap

func ToRockMap(ir InputReader) (Cave, error)

type CmdName

type CmdName int
const (
	NotSupported CmdName = iota
	LS
	CD
)

func GetCmdName

func GetCmdName(cmd string) CmdName

type CmdState

type CmdState struct {
	Cycle int
	Value int
	Saved []int
}

type Command

type Command struct {
	CMD    CmdName
	Args   []string
	Output []string
}

type CommandQueue

type CommandQueue []*Command

func ToCmdQueue

func ToCmdQueue(ir InputReader) (CommandQueue, error)

type Day16Inpt

type Day16Inpt struct {
	AdjacenyM      [][]int
	ValvesPressure map[int]int
}

func ToAdjacencyMatrix

func ToAdjacencyMatrix(ir InputReader) (Day16Inpt, error)

type Direction

type Direction int
const (
	UP Direction = iota
	DOWN
	LEFT
	RIGHT
)

func DirectionOf

func DirectionOf(s string) (Direction, error)

func ToDirections

func ToDirections(ir InputReader) ([]Direction, error)

type ElevationMap

type ElevationMap struct {
	Start  Point
	Finish Point
	Map    [][]int
}

func ToElevationMap

func ToElevationMap(ir InputReader) (ElevationMap, error)

type FileToStringsInputReader

type FileToStringsInputReader struct {
	Path string
	Opts Options
}

func (*FileToStringsInputReader) GetInput

func (fts *FileToStringsInputReader) GetInput() ([]string, error)

type InputReader

type InputReader interface {
	GetInput() ([]string, error)
}

type IntOrSpace

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

func ToIntOrSpaceArr

func ToIntOrSpaceArr(ir InputReader) ([]IntOrSpace, error)

type KnotMove

type KnotMove struct {
	Direction Direction
	Count     int
}

func ToMoves

func ToMoves(ir InputReader) ([]KnotMove, error)

type KnotsState

type KnotsState struct {
	Knots     []Point
	Recorders map[int]PosRecorder
}

type Line

type Line struct {
	From int
	To   int
}

func (Line) Contains

func (l Line) Contains(x int) bool

type Monkey

type Monkey struct {
	Items     []int
	Operation Operation
	Divisor   int
	IfTrue    int
	IfFalse   int
	Inspected int
}

type Monkeys

type Monkeys map[int]Monkey

func ToMonkeys

func ToMonkeys(ir InputReader) (Monkeys, error)

type Move

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

type Moves

type Moves []Move

type NodeType

type NodeType int
const (
	File NodeType = iota
	Dir
)

type Noop

type Noop struct {
	Cycle int
}

func NewNoopCmd

func NewNoopCmd() Noop

func (Noop) Execute

func (c Noop) Execute(s *CmdState, needSave func(cycle int, state int) bool, save func(cycle int, state int) int)

type OpArg

type OpArg struct {
	Type  OpArgType
	Value int
}

type OpArgType

type OpArgType int
const (
	Old OpArgType = iota
	Custom
)

type Operation

type Operation struct {
	Arg1 OpArg
	Arg2 OpArg
	Func func(arg1 int, arg2 int) int
}

func (Operation) Execute

func (op Operation) Execute(value int) int

type Options

type Options struct {
	TrimLine bool
}

type Point

type Point struct {
	X int
	Y int
}

type Point3D

type Point3D struct {
	X int
	Y int
	Z int
}

func ToArrPoint3D

func ToArrPoint3D(ir InputReader) ([]Point3D, error)

type PointStatus

type PointStatus struct {
	LeftFree  bool
	RightFree bool
	UpFree    bool
	DownFree  bool
	FrontFree bool
	BackFree  bool
}

type PointType

type PointType int
const (
	NotCovered PointType = iota
	Covered
	Sensor
	Beacon
)

type PosRecorder

type PosRecorder struct {
	Positions []Point
}

type RPS

type RPS int
const (
	R RPS = iota
	P
	S
)

func (RPS) Score

func (rps RPS) Score() int

type SandGrainState

type SandGrainState int
const (
	Falling SandGrainState = iota
	Fell
	InfinityFalling
)

type SearchState

type SearchState struct {
	MinLeft  int
	Pressure int
}

type Segment

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

type SensorBeacon

type SensorBeacon struct {
	Sensor Point
	Beacon Point
}

type SensorsBeaconsField

type SensorsBeaconsField struct {
	Points []SensorBeacon
	MaxX   int
	MinX   int
	MaxY   int
	MinY   int
}

func ToSensorsBeacons

func ToSensorsBeacons(ir InputReader) (SensorsBeaconsField, error)

type Side

type Side int

type Stack

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

type Stacks

type Stacks map[int]Stack

type StatefullCmd

type StatefullCmd interface {
	Execute(s *CmdState, needSave func(cycle int, state int) bool, save func(cycle int, state int) int)
}

func ToStatefulCmds

func ToStatefulCmds(ir InputReader) ([]StatefullCmd, error)

type Step

type Step struct {
	Destination Point
}

type Tree

type Tree struct {
	Type     NodeType
	Size     int
	Name     string
	Parent   *Tree
	Children map[string]*Tree
}

type TreeInfo

type TreeInfo struct {
	Hight  int
	VLeft  VStatus
	DLeft  int
	VTop   VStatus
	DTop   int
	VRight VStatus
	DRight int
	VBot   VStatus
	DBot   int
}

type TupleIntArr

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

func ToTupleIntArr

func ToTupleIntArr(ir InputReader) ([]TupleIntArr, error)

type TupleRPS

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

RPS stands for: Rock, Paper, Scissors

func ToTupleRPSArr

func ToTupleRPSArr(ir InputReader) ([]TupleRPS, error)

type TupleSegment

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

func ToTupleSegment

func ToTupleSegment(ir InputReader) ([]TupleSegment, error)

type TupleString

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

func ToArrTupleString

func ToArrTupleString(ir InputReader) ([]TupleString, error)

type VStatus

type VStatus int
const (
	NotVisible VStatus = iota
	NotVisibleSameHight
	Visible
)

Jump to

Keyboard shortcuts

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