Day 18 solution

This commit is contained in:
2021-12-19 00:27:21 +00:00
parent 56b9b82e60
commit 34c3b2da7e
11 changed files with 850 additions and 0 deletions

26
eighteen/main.go Normal file
View File

@@ -0,0 +1,26 @@
package eighteen
import "fmt"
type Eighteen struct {
snail snail
}
func Init(filepath string) *Eighteen {
eighteen := &Eighteen{
snail: snail{},
}
eighteen.snail.load(filepath)
return eighteen
}
func (d *Eighteen) Answer() string {
sum := d.snail.sum()
return fmt.Sprintf("The magnitude of the final sum is %d", sum.magnitude())
}
func (d *Eighteen) FollowUp() string {
return fmt.Sprintf("The largest magnitude of any two snail numbers is %d", d.snail.largestMagnitude())
}