Solution for Day 17

This commit is contained in:
2021-12-18 19:50:49 +00:00
parent 5c0b7a3b09
commit 56b9b82e60
7 changed files with 280 additions and 0 deletions

28
seventeen/main.go Normal file
View File

@@ -0,0 +1,28 @@
package seventeen
import "fmt"
type Seventeen struct {
probe probe
}
func Init(filepath string) *Seventeen {
seventeen := &Seventeen{
probe: probe{},
}
seventeen.probe.load(filepath)
return seventeen
}
func (d *Seventeen) Answer() string {
ivs := d.probe.intialVelocities()
return fmt.Sprintf("The max height is %d", maxHeight(d.probe, ivs))
}
func (d *Seventeen) FollowUp() string {
ivs := d.probe.intialVelocities()
return fmt.Sprintf("There are %d initial velocities that will hit the target", len(ivs))
}