Day 6 solution
This commit is contained in:
26
six/main.go
Normal file
26
six/main.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package six
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Six struct {
|
||||
lanternfish lanternfish
|
||||
}
|
||||
|
||||
func Init(filepath string) *Six {
|
||||
six := &Six{
|
||||
lanternfish: lanternfish{},
|
||||
}
|
||||
|
||||
six.lanternfish.load(filepath)
|
||||
return six
|
||||
}
|
||||
|
||||
func (d *Six) Answer() string {
|
||||
d.lanternfish.simulate(80)
|
||||
return fmt.Sprintf("After 80 days there are %d fish", d.lanternfish.population)
|
||||
}
|
||||
|
||||
func (d *Six) FollowUp() string {
|
||||
d.lanternfish.simulate(176)
|
||||
return fmt.Sprintf("After 256 days there are %d fish", d.lanternfish.population)
|
||||
}
|
Reference in New Issue
Block a user