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

58
seventeen/probe_test.go Normal file
View File

@@ -0,0 +1,58 @@
package seventeen
import (
"testing"
)
func Test_read(t *testing.T) {
p := probe{}
if err := p.load("test_input.txt"); err != nil {
t.Log(err)
t.FailNow()
}
if p.target.xMin != 20 {
t.Logf("Expected 20, found %d", p.target.xMin)
t.Fail()
}
if p.target.xMax != 30 {
t.Logf("Expected 30, found %d", p.target.xMax)
t.Fail()
}
if p.target.yMax != -5 {
t.Logf("Expected 20, found %d", p.target.xMin)
t.Fail()
}
if p.target.yMin != -10 {
t.Logf("Expected 30, found %d", p.target.xMax)
t.Fail()
}
}
func Test_initialVelocities(t *testing.T) {
p := probe{}
p.load("test_input.txt")
ivs := p.intialVelocities()
if len(ivs) != 112 {
t.Logf("Expected 112 initial velocities to target, found %d", len(ivs))
t.Fail()
}
}
func Test_maxHeight(t *testing.T) {
p := probe{}
p.load("test_input.txt")
ivs := p.intialVelocities()
max := maxHeight(p, ivs)
if max != 45 {
t.Logf("Expected max height of 45, found %d", max)
t.Fail()
}
}