feat: add move method to position

This commit is contained in:
Stevan Freeborn
2025-12-13 07:28:13 -06:00
parent 575638e449
commit 934ac56ab6
2 changed files with 19 additions and 0 deletions
+7
View File
@@ -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())
}