remove log.Fatal's from solve.go, return values back to main.

This commit is contained in:
onyx-and-iris 2024-12-02 18:30:26 +00:00
parent 600d01660c
commit 67a04b91c8
3 changed files with 15 additions and 13 deletions

View File

@ -25,5 +25,10 @@ func main() {
log.Fatal(err)
}
problems.Solve(data)
one, two, err := problems.Solve(data)
if err != nil {
log.Fatal(err)
}
fmt.Printf("solution one: %d\nsolution two: %d\n", one, two)
}

View File

@ -1,23 +1,20 @@
package day01
package dayone
import (
"fmt"
"log"
"github.com/onyx-and-iris/aoc2024/day-01/internal/one"
"github.com/onyx-and-iris/aoc2024/day-01/internal/two"
)
func Solve(data []byte) {
val, err := one.Solve(data)
func Solve(data []byte) (int, int, error) {
answerOne, err := one.Solve(data)
if err != nil {
log.Fatal(err)
return 0, 0, err
}
fmt.Printf("solution one: %d\n", val)
val, err = two.Solve(data)
answerTwo, err := two.Solve(data)
if err != nil {
log.Fatal(err)
return 0, 0, err
}
fmt.Printf("solution two: %d\n", val)
return answerOne, answerTwo, nil
}

View File

@ -1,4 +1,4 @@
package day01
package dayone
import (
_ "embed"