-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday13_2.go
31 lines (24 loc) · 811 Bytes
/
day13_2.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package day13
import (
"strings"
"github.com/blfuentes/AdventOfCode_2024_Go/utilities"
)
func Executepart2() int64 {
var result int64 = 0
var fileName string = "./day13/day13.txt"
var extra int64 = 10000000000000
if fileContent, err := utilities.ReadFileAsText(fileName); err == nil {
equations := strings.Split(fileContent, "\r\n\r\n")
toSolve := make([]Combination, 0)
for _, eq := range equations {
aX, aY := ExtractNumbers(strings.Split(eq, "\n")[0])
bX, bY := ExtractNumbers(strings.Split(eq, "\n")[1])
rX, rY := ExtractNumbers(strings.Split(eq, "\n")[2])
ecuation := Combination{Push{aX, aY}, Push{bX, bY}, rX + extra, rY + extra}
toSolve = append(toSolve, ecuation)
resultA, resultB := SolveEquation(ecuation)
result += resultA*3 + resultB
}
}
return result
}