mirror of
https://github.com/onyx-and-iris/aoc2023.git
synced 2024-11-15 15:10:49 +00:00
33 lines
647 B
Go
33 lines
647 B
Go
|
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)
|
||
|
}
|