feat: add move method to position
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
// Package position provides types and functions to represent and manipulate positions and moves on a 2D grid.
|
||||
package position
|
||||
|
||||
import "github.com/StevanFreeborn/advent-of-code-2025/internal/move"
|
||||
|
||||
type Position interface {
|
||||
Row() int
|
||||
Column() int
|
||||
Move(move.Move) Position
|
||||
}
|
||||
|
||||
type position struct {
|
||||
@@ -25,3 +28,7 @@ func (p position) Row() int {
|
||||
func (p position) Column() int {
|
||||
return p.column
|
||||
}
|
||||
|
||||
func (p position) Move(move move.Move) Position {
|
||||
return From(p.row+move.NumberOfRows(), p.column+move.NumberOfColumns())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user