advent_of_code_2024/main.go

39 lines
949 B
Go
Raw Normal View History

2024-12-01 09:55:43 +00:00
package main
import (
"advent_of_code_2024/day_01"
_ "embed"
"fmt"
"os"
)
func main() {
selectedDay := selectSolutionRun()
switch selectedDay {
case "01-basic":
fmt.Printf("Day 01. Basic: %d\n", day_01.SolveBasic(Day01Data)) // 2113135
case "01-complex":
fmt.Printf("Day 01. Complex: %d\n", day_01.SolveComplex(Day01Data)) // 19097157
}
}
func selectSolutionRun() string {
selectedDay := ""
if len(os.Args) == 2 {
// if command line arg passed use that
selectedDay = os.Args[1]
} else if len(os.Args) == 1 {
// otherwise ask user for the solution
fmt.Printf("Enter the solution to be run: e.g. 01-basic,21-complex...\n")
if _, err := fmt.Scan(&selectedDay); err != nil {
panic(err)
}
} else {
// if too many arguments are passed return error message
fmt.Printf("Invalid number of arguments\nUsage: %s day-basic|day-complex\n e.g. %s 01-basic", os.Args[0], os.Args[0])
os.Exit(1)
}
return selectedDay
}