mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2025-01-10 14:50:46 +00:00
40 lines
600 B
Go
40 lines
600 B
Go
|
package machine
|
||
|
|
||
|
import "fmt"
|
||
|
|
||
|
type Button struct {
|
||
|
X int
|
||
|
Y int
|
||
|
}
|
||
|
|
||
|
type Prize struct {
|
||
|
X int
|
||
|
Y int
|
||
|
}
|
||
|
|
||
|
type Machine struct {
|
||
|
A Button
|
||
|
B Button
|
||
|
Prize Prize
|
||
|
}
|
||
|
|
||
|
func New(btnA, btnB, prz []string) *Machine {
|
||
|
return &Machine{
|
||
|
A: Button{X: mustConv(btnA[2]), Y: mustConv(btnA[3])},
|
||
|
B: Button{X: mustConv(btnB[2]), Y: mustConv(btnB[3])},
|
||
|
Prize: Prize{X: mustConv(prz[1]), Y: mustConv(prz[2])},
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (m *Machine) String() string {
|
||
|
return fmt.Sprintf(
|
||
|
"ButtonA: (%d,%d) ButtonB: (%d,%d) Prize: (%d,%d)",
|
||
|
m.A.X,
|
||
|
m.A.Y,
|
||
|
m.B.X,
|
||
|
m.B.Y,
|
||
|
m.Prize.X,
|
||
|
m.Prize.Y,
|
||
|
)
|
||
|
}
|