aoc2023/day-17/node.go

33 lines
647 B
Go
Raw Permalink Normal View History

2023-12-22 21:56:07 +00:00
package main
import "fmt"
type coords struct {
X int
Y int
}
func newCoords(x, y int) coords {
return coords{X: x, Y: y}
}
// node represents a single point on the graph
type node struct {
cost int
distance int
directionX int
directionY int
coords
index int
}
func newNode(cost, distance, directionX, directionY, x, y int) *node {
c := newCoords(x, y)
return &node{cost: cost, distance: distance, directionX: directionX, directionY: directionY, coords: c}
}
// String implements the fmt.Stringer interface
func (n node) String() string {
return fmt.Sprintf("%d%d%d%v", n.distance, n.directionX, n.directionY, n.coords)
}