advent_of_code_2024/main.go

79 lines
2.7 KiB
Go

package main
import (
"advent_of_code_2024/day_01"
"advent_of_code_2024/day_02"
"advent_of_code_2024/day_03"
"advent_of_code_2024/day_04"
"advent_of_code_2024/day_05"
"advent_of_code_2024/day_06"
"advent_of_code_2024/day_07"
"advent_of_code_2024/day_08"
"advent_of_code_2024/day_09"
_ "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
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
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
case "04-basic":
fmt.Printf("Day 04. Basic: %d\n", day_04.SolveBasic(Day04Data)) // 2560
case "04-complex":
fmt.Printf("Day 04. Complex: %d\n", day_04.SolveComplex(Day04Data)) // 1980
case "05-basic":
fmt.Printf("Day 05. Basic: %d\n", day_05.SolveBasic(Day05Data)) // 2560
case "05-complex":
fmt.Printf("Day 05. Complex: %d\n", day_05.SolveComplex(Day05Data)) // 63013756
case "06-basic":
fmt.Printf("Day 06. Basic: %d\n", day_06.SolveBasic(Day06Data)) //
case "06-complex":
fmt.Printf("Day 06. Complex: %d\n", day_06.SolveComplex(Day06Data)) //
case "07-basic":
fmt.Printf("Day 07. Basic: %d\n", day_07.SolveBasic(Day07Data)) // 20665830408335
case "07-complex":
fmt.Printf("Day 07. Complex: %d\n", day_07.SolveComplex(Day07Data)) // 20665830408335
case "08-basic":
fmt.Printf("Day 08. Basic: %d\n", day_08.SolveBasic(Day08Data)) // 20665830408335
case "08-complex":
fmt.Printf("Day 08. Complex: %d\n", day_08.SolveComplex(Day08Data)) // 20665830408335
case "09-basic":
fmt.Printf("Day 09. Basic: %d\n", day_09.SolveBasic(Day09Data)) // 20665830408335
case "09-complex":
fmt.Printf("Day 09. Complex: %d\n", day_09.SolveComplex(Day09Data)) // 20665830408335
}
}
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
}