Day 8 solution

This commit is contained in:
2021-12-08 14:51:00 +00:00
parent f2e471f2a4
commit b62022ff07
7 changed files with 503 additions and 0 deletions

26
eight/main.go Normal file
View File

@@ -0,0 +1,26 @@
package eight
import "fmt"
type Eight struct {
display display
}
func Init(filepath string) *Eight {
eight := &Eight{
display: display{},
}
eight.display.load(filepath)
return eight
}
func (d *Eight) Answer() string {
count := d.display.uniqueOuputs()
return fmt.Sprintf("There were %d instances of digits 1, 4, 7, or 8", count)
}
func (d *Eight) FollowUp() string {
outputSum := d.display.outputSum()
return fmt.Sprintf("The sum of the decoded output values was %d", outputSum)
}