36 lines
770 B
Go
36 lines
770 B
Go
package main
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
|
|
"github.com/StevanFreeborn/advent-of-code-2025/cmd/06/problem"
|
|
"github.com/StevanFreeborn/advent-of-code-2025/internal/file"
|
|
)
|
|
|
|
func SolvePartOne(filePath string) int {
|
|
input := file.ReadAllLines(filePath)
|
|
numOfRows := len(input)
|
|
numOfCols := len(strings.Fields(input[0]))
|
|
operatorRowNumber := numOfRows - 1
|
|
operators := strings.Fields(input[operatorRowNumber])
|
|
|
|
total := 0
|
|
|
|
for col := range numOfCols {
|
|
operator := operators[col]
|
|
operands := []int{}
|
|
|
|
for row := range operatorRowNumber {
|
|
operand, _ := strconv.Atoi(strings.Fields(input[row])[col])
|
|
operands = append(operands, operand)
|
|
}
|
|
|
|
problem := problem.From(operator, operands)
|
|
result := problem.Solve()
|
|
total += result
|
|
}
|
|
|
|
return total
|
|
}
|