Day 6 solution

This commit is contained in:
2021-12-06 14:08:30 +00:00
parent 4f1fddf0eb
commit 84a1d25dbe
7 changed files with 150 additions and 0 deletions

44
six/lanternfish_test.go Normal file
View File

@@ -0,0 +1,44 @@
package six
import "testing"
func Test_read(t *testing.T) {
l := lanternfish{}
if err := l.load("test_input.txt"); err != nil {
t.Log(err)
t.FailNow()
}
if l.population != 5 {
t.Logf("Expected 5 fish, found %d", l.population)
t.Fail()
}
}
func Test_simulate(t *testing.T) {
l := lanternfish{}
l.load("test_input.txt")
l.simulate(18)
if l.population != 26 {
t.Logf("Expected 26 fish, found %d", l.population)
t.Fail()
}
l.simulate(62)
if l.population != 5934 {
t.Logf("Expected 5934 fish, found %d", l.population)
t.Fail()
}
}
func Test_simulateForever(t *testing.T) {
l := lanternfish{}
l.load("test_input.txt")
l.simulate(256)
if l.population != 26984457539 {
t.Logf("Expected 26984457539 fish, found %d", l.population)
t.Fail()
}
}