2024-12-01 09:55:43 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"advent_of_code_2024/day_01"
|
2024-12-03 18:35:51 +00:00
|
|
|
"advent_of_code_2024/day_02"
|
2024-12-03 19:05:59 +00:00
|
|
|
"advent_of_code_2024/day_03"
|
2024-12-01 09:55:43 +00:00
|
|
|
_ "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
|
2024-12-03 18:35:51 +00:00
|
|
|
case "02-basic":
|
|
|
|
fmt.Printf("Day 02. Basic: %d\n", day_02.SolveBasic(Day02Data)) // 690
|
|
|
|
case "02-complex":
|
|
|
|
fmt.Printf("Day 02. Complex: %d\n", day_02.SolveComplex(Day02Data)) // 710
|
2024-12-03 19:05:59 +00:00
|
|
|
case "03-basic":
|
|
|
|
fmt.Printf("Day 03. Basic: %d\n", day_03.SolveBasic(Day03Data)) // 189527826
|
|
|
|
case "03-complex":
|
|
|
|
fmt.Printf("Day 03. Complex: %d\n", day_03.SolveComplex(Day03Data)) // 63013756
|
2024-12-01 09:55:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|