days

package
v0.0.0-...-2894559 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Blink(stones []string) []string

rules: 1. 0 -> 1 2. #a#b -> a | b 3. X -> 2024*X 0 1 10 99 999

func Display

func Display(reports []Report, verbose bool)

func FindAllPaths

func FindAllPaths(goalNode *Node, optimalScore int, costMap map[P]int) [][]P

func GenerateStones

func GenerateStones(data string) int

func GetDays

func GetDays() map[string][]string

func GetInt

func GetInt(str string) int

func GetInt64

func GetInt64(str string) int64

func GetKey

func GetKey(x int, y int) string

func GetPlayerRune

func GetPlayerRune(c CellType) rune

func GetSeq

func GetSeq(a, b, c, d int) string

func GetTileKey

func GetTileKey(x int, y int) string

func Heuristic

func Heuristic(a, b P) int

func IsValid

func IsValid(grid [][]int, p P) bool

func MD5

func MD5(in string) string

func MakeGrid

func MakeGrid(data []string) ([][]int, P, P)

func NumCache

func NumCache(n string) int

func PKey

func PKey(x int, y int, d int) string

func PrepareDataA

func PrepareDataA(lines []string) ([]*OpTree, []*OpTree)

func PrepareDataB

func PrepareDataB(lines []string) ([]*OpTree, []*OpTree)

func PrintDebug

func PrintDebug(title string, debug []string)

func PrintError

func PrintError(err error)

func ReadFile

func ReadFile(path string) (string, error)

func ReadLines

func ReadLines(path string) ([]string, error)

func Reverse

func Reverse(s string) (result string)

func Run

func Run(days []string, verbose bool, test bool, runAll bool, input string)

func RunAStarTest

func RunAStarTest(data []string) int

func Solve12

func Solve12(data []string, verbose bool, price2 bool) int

func StrCache

func StrCache(i int) string

func Stringify

func Stringify(path []OutNode) string

func TestAlternates

func TestAlternates(data []string, pathKey string) int

func UNUSED

func UNUSED(x ...interface{})

var term_w, term_h int

Types

type Antenna

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

type AntiNode

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

type Arcade

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

func CreateArcade

func CreateArcade(data []string, add int64) []*Arcade

func (*Arcade) FindIntersection

func (a *Arcade) FindIntersection(verbose bool) (*ArcadeButton, bool)

FindIntersection finds the intersection point of two vectors or returns false if they do not intersect

func (*Arcade) Solve

func (a *Arcade) Solve(verbose bool) int64

type ArcadeButton

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

func MakeButton

func MakeButton(line string) *ArcadeButton

type ArcadePrize

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

func MakePrize

func MakePrize(line string, add int64) *ArcadePrize

type Bathroom

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

func (*Bathroom) Clear

func (b *Bathroom) Clear()

func (*Bathroom) Load

func (b *Bathroom) Load(data []string)

func (*Bathroom) Render

func (b *Bathroom) Render()

func (*Bathroom) Run

func (b *Bathroom) Run(data []string, verbose bool)

func (*Bathroom) RunTick

func (b *Bathroom) RunTick()

func (*Bathroom) Update

func (b *Bathroom) Update()

func (*Bathroom) UpdateBack

func (b *Bathroom) UpdateBack()

func (*Bathroom) WaitForTick

func (b *Bathroom) WaitForTick()

type Block

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

type BlockStore

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

func ReadDisk

func ReadDisk(data string) *BlockStore

func (*BlockStore) CheckSum

func (b *BlockStore) CheckSum(report *Report) int

func (*BlockStore) Compress

func (b *BlockStore) Compress(verbose bool)

func (*BlockStore) Compress2

func (b *BlockStore) Compress2(verbose bool)

func (*BlockStore) Render

func (b *BlockStore) Render(start_idx int, end_idx int) string

type Bounds

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

func (*Bounds) Update

func (b *Bounds) Update(p *Plant)

type Box

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

func (*Box) GPS

func (b *Box) GPS() int

type Cell

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

func (*Cell) SetTrap

func (c *Cell) SetTrap(p *Player)

type CellType

type CellType string
const (
	OPEN        CellType = "OPEN"
	TOP_BOT     CellType = "TOP_BOT"
	WALL        CellType = "WALL"
	CORNER      CellType = "CORNER"
	PLAYER_U    CellType = "PLAYER_U"
	PLAYER_D    CellType = "PLAYER_D"
	PLAYER_L    CellType = "PLAYER_L"
	PLAYER_R    CellType = "PLAYER_R"
	OBSTRUCTION CellType = "OBSTRUCTION"
	TEST_TRAP   CellType = "TEST_TRAP"
	FOUND_TRAP  CellType = "FOUND_TRAP"
	EXIT        CellType = "EXIT"
	ERROR       CellType = "ERROR"
	UNKNOWN     CellType = "UNKNOWN"
)

func GetCellType

func GetCellType(r rune) CellType

func GetPlayerCellType

func GetPlayerCellType(r rune) CellType

type Coords

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

type Direction

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

type Failure

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

type Game

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

func NewGame

func NewGame(level []string) *Game

func (*Game) SkipDuplicates

func (g *Game) SkipDuplicates() *Cell

func (*Game) Start

func (g *Game) Start()

func (*Game) Trap

func (g *Game) Trap(first bool)

func (*Game) TrapUpdate

func (g *Game) TrapUpdate()

func (*Game) Update

func (g *Game) Update()

type GameState

type GameState string
const (
	SETUP      GameState = "SETUP"
	RUN        GameState = "RUN"
	OBSTRUCTED GameState = "OBSTRUCTED"
	LEAVE      GameState = "LEAVE"
	TRAP       GameState = "TRAP"
	TEST       GameState = "TEST"
	TRAP_FOUND GameState = "TRAP_FOUND"
	DONE       GameState = "DONE"
)

type Garden

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

func CreateGarden

func CreateGarden(cells []string) *Garden

func (*Garden) CreatePlots

func (g *Garden) CreatePlots()

func (*Garden) GetPlant

func (g *Garden) GetPlant(x, y int) *Plant

type Island

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

func GenerateIsland

func GenerateIsland(data []string) *Island

func (*Island) GeneratePaths

func (i *Island) GeneratePaths()

func (*Island) GetCell

func (i *Island) GetCell(y int, x int) *PathCell

func (*Island) Render

func (i *Island) Render()

func (*Island) ScoreTrails

func (i *Island) ScoreTrails(all bool)

type KeyPad

type KeyPad struct {
	Y int
	X int
	// contains filtered or unexported fields
}

type LL

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

func GenerateList

func GenerateList(instructions []string) *LL

type LanternStones

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

type Lexer

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

func NewLexer

func NewLexer(input string, respectRules bool) *Lexer

func (*Lexer) NextToken

func (l *Lexer) NextToken() Token

type Line

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

type Lines

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

type Map2D

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

type Net

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

type NetSet

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

func NewNet

func NewNet() *NetSet

func (*NetSet) Add

func (n *NetSet) Add(val string)

func (*NetSet) Contains

func (n *NetSet) Contains(val string) bool

func (*NetSet) Intersection

func (n *NetSet) Intersection(other *NetSet) *NetSet

func (*NetSet) List

func (n *NetSet) List() []string

func (*NetSet) Remove

func (n *NetSet) Remove(val string)

func (*NetSet) Size

func (n *NetSet) Size() int

func (*NetSet) String

func (n *NetSet) String() string

func (*NetSet) Union

func (n *NetSet) Union(other *NetSet) *NetSet

type Node

type Node struct {
	Position P
	GCost    int
	HCost    int
	FCost    int
	Prev     *Node
	PrevDir  P
	Path     []P
	Cheat    int
}

type Op

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

type OpTree

type OpTree struct {
	Parent *OpTree

	Expected int

	Multiply      *OpTree
	MultiplyValid bool

	Concat      *OpTree
	ConcatValid bool

	Add      *OpTree
	AddValid bool

	Value int
	Valid bool
}

func MakeOpTree

func MakeOpTree(yourValue int, expected int, values []int, p *OpTree) (*OpTree, bool)

func MakeOpTreeConcat

func MakeOpTreeConcat(yourValue int, expected int, values []int, p *OpTree) (*OpTree, bool)

type OptionFunc

type OptionFunc struct {
	MaxDepth int
}

type OutNode

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

func AStarWithPenalty

func AStarWithPenalty(grid [][]int, start, goal P, weight *P) []OutNode

func GetAStarPath

func GetAStarPath(data []string, reverse bool, weight *P, pathList map[string]int, weights []*P) []OutNode

type P

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

type Page

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

func (*Page) CanView

func (p *Page) CanView(nextPage string) bool

type PathCell

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

func (*PathCell) GetNeighbors

func (c *PathCell) GetNeighbors(i *Island)

func (*PathCell) ScorePath

func (cell *PathCell) ScorePath(th *TrailHead, all bool) int

type Plant

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

type Player

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

func NewPlayer

func NewPlayer() *Player

func (*Player) CanMove

func (p *Player) CanMove(g *Game) bool

func (*Player) EndTrapTest

func (p *Player) EndTrapTest(g *Game)

func (*Player) GetRune

func (p *Player) GetRune() rune

func (*Player) Leave

func (p *Player) Leave(g *Game) bool

func (*Player) Looping

func (p *Player) Looping(g *Game) bool

func (*Player) Move

func (p *Player) Move(g *Game)

func (*Player) Obstructed

func (p *Player) Obstructed(g *Game) bool

func (*Player) ObstructionRight

func (p *Player) ObstructionRight(g *Game) bool

func (*Player) SetDirection

func (p *Player) SetDirection(r rune) Direction

func (*Player) TrapSuccess

func (p *Player) TrapSuccess(g *Game)

func (*Player) TrapUpdate

func (p *Player) TrapUpdate(g *Game)

func (*Player) Turn

func (p *Player) Turn(g *Game)

func (*Player) Update

func (p *Player) Update(g *Game)

func (*Player) Win

func (p *Player) Win(g *Game)

type Plot

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

func (*Plot) BoundType

func (p *Plot) BoundType(sx int, sy int) string

sx = search x, sy = searchy

func (*Plot) CollectNeighbors

func (p *Plot) CollectNeighbors(pl *Plant, g *Garden)

func (*Plot) CreatePerim

func (p *Plot) CreatePerim(g *Garden)

func (*Plot) GenerateBed

func (p *Plot) GenerateBed(x int, y int, g *Garden)

func (*Plot) InnerPerim

func (p *Plot) InnerPerim() int

func (*Plot) OuterPerim

func (p *Plot) OuterPerim() int

func (*Plot) RenderPlant

func (p *Plot) RenderPlant(plant *Plant, c map[string]string)

func (*Plot) Sides

func (p *Plot) Sides() int

func (*Plot) StoreBounds

func (p *Plot) StoreBounds(pl *Plant)

type PriQueue

type PriQueue []*Node

func (PriQueue) Len

func (pq PriQueue) Len() int

func (PriQueue) Less

func (pq PriQueue) Less(i, j int) bool

func (*PriQueue) Pop

func (pq *PriQueue) Pop() interface{}

func (*PriQueue) Push

func (pq *PriQueue) Push(x interface{})

func (PriQueue) Swap

func (pq PriQueue) Swap(i, j int)

type Processor

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

func NewProcessor

func NewProcessor() *Processor

func (*Processor) CreateRules

func (p *Processor) CreateRules(rules []string) *RuleSet

func (*Processor) CreateUpdates

func (p *Processor) CreateUpdates(updates []string)

type Report

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

func BlankDay

func BlankDay(day string, verbose bool, test bool, input string) Report

func Day10a

func Day10a(verbose bool, test bool, input string) Report

func Day10b

func Day10b(verbose bool, test bool, input string) Report

func Day11

func Day11(day string, blink int, verbose bool, test bool, input string) Report

func Day11a

func Day11a(verbose bool, test bool, input string) Report

func Day11b

func Day11b(verbose bool, test bool, input string) Report

func Day11c

func Day11c(verbose bool, test bool, input string) Report

func Day12a

func Day12a(verbose bool, test bool, input string) Report

func Day12b

func Day12b(verbose bool, test bool, input string) Report

func Day13a

func Day13a(verbose bool, test bool, input string) Report

func Day13b

func Day13b(verbose bool, test bool, input string) Report

func Day14a

func Day14a(verbose bool, test bool, input string) Report

func Day15a

func Day15a(verbose bool, test bool, input string) Report

func Day15b

func Day15b(verbose bool, test bool, input string) Report

func Day16a

func Day16a(verbose bool, test bool, input string) Report

func Day16b

func Day16b(verbose bool, test bool, input string) Report

func Day17a

func Day17a(verbose bool, test bool, input string) Report

func Day17b

func Day17b(verbose bool, test bool, input string) Report

func Day18a

func Day18a(verbose bool, test bool, input string) Report

func Day18b

func Day18b(verbose bool, test bool, input string) Report

func Day19a

func Day19a(verbose bool, test bool, input string) Report

func Day19b

func Day19b(verbose bool, test bool, input string) Report

func Day1a

func Day1a(verbose bool, test bool, input string) Report

func Day1b

func Day1b(verbose bool, test bool, input string) Report

func Day20a

func Day20a(verbose bool, test bool, input string) Report

func Day20b

func Day20b(verbose bool, test bool, input string) Report

func Day21a

func Day21a(verbose bool, test bool, input string) Report

func Day21b

func Day21b(verbose bool, test bool, input string) Report

func Day22a

func Day22a(verbose bool, test bool, input string) Report

func Day22b

func Day22b(verbose bool, test bool, input string) Report

func Day23a

func Day23a(verbose bool, test bool, input string) Report

func Day23b

func Day23b(verbose bool, test bool, input string) Report

func Day2a

func Day2a(verbose bool, test bool, input string) Report

func Day2b

func Day2b(verbose bool, test bool, input string) Report

in part 2, we can remove a single bad level to see if that will allow a failing test to pass when it wouldn't have previously

func Day3a

func Day3a(verbose bool, test bool, input string) Report

func Day3b

func Day3b(verbose bool, test bool, input string) Report

func Day4a

func Day4a(verbose bool, test bool, input string) Report

func Day4b

func Day4b(verbose bool, test bool, input string) Report

func Day5a

func Day5a(verbose bool, test bool, input string) Report

func Day5b

func Day5b(verbose bool, test bool, input string) Report

func Day6a

func Day6a(verbose bool, test bool, input string) Report

^,>,v,< guard # obstruction

func Day6b

func Day6b(verbose bool, test bool, input string) Report

func Day7a

func Day7a(verbose bool, test bool, input string) Report

func Day7b

func Day7b(verbose bool, test bool, input string) Report

func Day8a

func Day8a(verbose bool, test bool, input string) Report

func Day8b

func Day8b(verbose bool, test bool, input string) Report

func Day9a

func Day9a(verbose bool, test bool, input string) Report

func Day9b

func Day9b(verbose bool, test bool, input string) Report

type Robot

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

type RoutePath

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

type RuleSet

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

func NewRuleSet

func NewRuleSet() *RuleSet

func (*RuleSet) AddPage

func (r *RuleSet) AddPage(left string, right string)

func (*RuleSet) FindOrStub

func (r *RuleSet) FindOrStub(page string) (*Page, error)

func (*RuleSet) GetPage

func (r *RuleSet) GetPage(page string) (*Page, error)

func (*RuleSet) Stub

func (r *RuleSet) Stub(page string) (*Page, error)

type SCell

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

type SRobot

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

func (*SRobot) GetDir

func (r *SRobot) GetDir(ins string) [2]int

type SeqDelta

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

type Sokoban

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

func (*Sokoban) CanMoveY

func (s *Sokoban) CanMoveY(blockCell *SCell, dir [2]int) bool

func (*Sokoban) Current

func (s *Sokoban) Current() []*SCell

func (*Sokoban) GetNext

func (s *Sokoban) GetNext(x int, y int, dir [2]int) *SCell
func (s *Sokoban) CastToEmpty(xL int, xR, y int, dir [2]int) *SCell {
	cells := s.Current()

	nxL := dir[0] + xL
	nxR := dir[0] + xR

	if nxL < 0 || ny < 0 || ny >= s.height || nxR > s.width*s.cellw {
		return &SCell{invalid: true}
	}

	cellL := cells[nxL+(ny*s.cellw*s.width)]
	cellR := cells[nxR+(ny*s.cellw*s.width)]
}

func (*Sokoban) Load

func (s *Sokoban) Load(data []string)

func (*Sokoban) Move

func (s *Sokoban) Move(dir [2]int)

func (*Sokoban) MoveBlockY

func (s *Sokoban) MoveBlockY(blockCell *SCell, dir [2]int) bool

func (*Sokoban) MoveBlocks

func (s *Sokoban) MoveBlocks(blockCell *SCell, dir [2]int) bool

func (*Sokoban) Render

func (s *Sokoban) Render()

func (*Sokoban) Tick

func (s *Sokoban) Tick() bool

type ThreeBit

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

func (*ThreeBit) Next

func (tb *ThreeBit) Next() *Op

func (*ThreeBit) ReadProgram

func (tb *ThreeBit) ReadProgram(data []string)

type Tile

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

type TileType

type TileType string
const (
	T_OPEN     TileType = "OPEN"
	T_TOP_BOT  TileType = "TOP_BOT"
	T_WALL     TileType = "WALL"
	T_CORNER   TileType = "CORNER"
	T_ANTENNA  TileType = "ANTENNA"
	T_ANTINODE TileType = "ANTINODE"
	T_UNKNOWN  TileType = "UNKNOWN"
)

func GetTileType

func GetTileType(d string) TileType

type Token

type Token struct {
	Type   TokenType
	Value  string
	Active bool
	Num1   int
	Num2   int
}

type TokenType

type TokenType string
const (
	COMMAND    TokenType = "COMMAND"
	ENABLE     TokenType = "ENABLE"
	DISABLE    TokenType = "DISABLE"
	OPENPAREN  TokenType = "OPENPAREN"
	NUMBER     TokenType = "NUMBER"
	CLOSEPAREN TokenType = "CLOSEPAREN"
	SEPARATOR  TokenType = "SEPARATOR"
	ILLEGAL    TokenType = "ILLEGAL"
	EOF        TokenType = "EOF"
)

type Trail

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

type TrailHead

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

func (*TrailHead) BuildTrails

func (th *TrailHead) BuildTrails(i *Island, all bool)

type Update

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

func NewUpdate

func NewUpdate(path string) *Update

func (*Update) Fix

func (u *Update) Fix(r *RuleSet) *Update

correct the rule update order using sort function to sort the path by our existing rule engine

func (*Update) Validate

func (u *Update) Validate(r *RuleSet) *Update

type Velocity

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

type Wall

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

type World

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

func NewWorld

func NewWorld(level []string) *World

func (*World) Visited

func (w *World) Visited(g *Game, cell *Cell, tick int)

type WorldD

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

func NewWorldD

func NewWorldD(level []string) *WorldD

func (*WorldD) GenerateAntennaNetwork

func (w *WorldD) GenerateAntennaNetwork(freq string, a *Antenna, resonant bool)

func (*WorldD) GenerateAntiNodes

func (w *WorldD) GenerateAntiNodes(resonant bool)

func (*WorldD) GenerateNetwork

func (w *WorldD) GenerateNetwork(resonant bool)

func (*WorldD) ValidAntiNode

func (w *WorldD) ValidAntiNode(x int, y int) bool

antennas map[string][]*Antenna antiNodes map[string][]*AntiNode

Jump to

Keyboard shortcuts

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